+ All Categories
Home > Documents > Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner,...

Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner,...

Date post: 16-Aug-2020
Category:
Upload: others
View: 10 times
Download: 0 times
Share this document with a friend
16
Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting
Transcript
Page 1: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Git / MercurialDistributed Revision Control Systems

Pascal Pfiffner, January 25th, Bern Computational Biology Meeting

Page 2: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Architecture

• No Server/Client paradigm

• Complete history resides in one subdirectory (.git / .hg)

• Each checkout contains the complete history

• Advanced merging

➔ Fast local transactions, network independence

Page 3: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Why to use Revision Control

• Light-heartedly work on code – you can always go back

• Ever deleted a file that you’re “never going to need again”?

• Work on different machines

➔ Personal use: Everything code, LaTeX (papers, proposals)

Page 4: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

How to start• Git or Mercurial? Virtually the same. You can use either,

conversion tools (complete history) are available.

• Beginner? Use Git (helpful command line comments)

• Social coding:http://www.github.com/ (free public repositories)http://gitorious.org/ (free private repositories)http://www.bitbucket.org/ (free private repositories)

• Download and install:Git: http://git-scm.com/Mercurial: http://mercurial.selenic.com/

Page 5: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Create a Repository

• For empty and existing repositories:mkdir project && cd projectgit/hg init

• Adding existing files:git/hg add <files>

Page 6: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Committing

• Commits are local, thus fast

• Git only commits files, also existing files, previously add-ed. Commits all changes with the -a switch. Mercurial commits all changes unless specific files are specified.

git commit -a -m “Message”

hg commit -m “Message”

Page 7: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Working

• See statusgit/hg statusgit/hg loggit/hg diff...

• Add, move and remove fileshg/git add/mv/rm

• Ignore certain files: Write names as shell-patters into:.gitignore / .hgignore

Page 8: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Much much more

• Get cheat-sheets:

• Git: http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html

• Mercurial: http://ivy.fr/mercurial/ref/v1.0/

Page 9: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Publish your repository

•Don’t use your working copy, create a clone to pull fromgit clone --bare project /share/git/project.githg clone project /share/hg/project.hg

• Many serving possibilities (HTTP, HTTPS, Samba, NFS)

• For yourself: Just use SSH, no additional setup required

Page 10: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Fetching remote repositories

• Initially: Clone the repo from remotegit clone ssh://[email protected]/share/git/project.githg clone ssh://[email protected]/share/hg/project.hg

• In the future: Pull and merge changes

git pull (or :)git fetch && git mergehg pull && hg merge

Page 11: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Share your commits

• After your commits are done, you push them. Both systems push a cloned repository to where it was cloned from

git/hg push

• But you can push to different locations

Page 12: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Graphical Interfaces

• Simplify many of the daily tasks

• No additional setup

• Best: Visually check your changes before committing

• My choice:Git: GitX: http://gitx.frim.nl/Mercurial: Murky: https://bitbucket.org/snej/murky

Page 13: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

GitX: Stage commit

Page 14: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

GitX: View history, push

Page 15: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Murky: Stage commit

Page 16: Git / Mercurial - Portal · Git / Mercurial Distributed Revision Control Systems Pascal Pfiffner, January 25th, Bern Computational Biology Meeting. Architecture ... • No additional

Further Reading

• Check out advanced possibilites like branching, cherry-picking and blaming

• Documentation:

• Git: http://git-scm.com/documentationMercurial: http://hgbook.red-bean.com/


Recommended