User Tools

Site Tools


how_to_work_with_git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to_work_with_git [2017/10/02 11:55]
tsaue
how_to_work_with_git [2017/10/02 15:20] (current)
tsaue
Line 4: Line 4:
 Git is a program that helps multiple developers work together on a program simultaneously. Every revision to the source code is retained, so if something goes wrong it is always possible to go back to a previous state. ​ Git is a program that helps multiple developers work together on a program simultaneously. Every revision to the source code is retained, so if something goes wrong it is always possible to go back to a previous state. ​
  
-=== Main differences that surprise Subversion users ===+===== Main differences that surprise Subversion users =====
  
 You can probably skip this if you have never worked with Subversion or CVS.  You can probably skip this if you have never worked with Subversion or CVS. 
Line 15: Line 15:
  
 ''​git checkout''​ is at first sight rather different from ''​svn checkout''​. You can use ''​git checkout''​ to switch to another branch or to revert modifications but not to clone the repository. However, the more you use Git the more ''​git checkout''​ will resemble ''​svn checkout''​. ''​git checkout''​ is at first sight rather different from ''​svn checkout''​. You can use ''​git checkout''​ to switch to another branch or to revert modifications but not to clone the repository. However, the more you use Git the more ''​git checkout''​ will resemble ''​svn checkout''​.
 +
 +===== Before you start working with git =====
 +
 +It is highly recommended to set the following for the optimum git experience: Colorize your life! 
 +
 +   $ git config --global color.branch auto
 +   $ git config --global color.diff ​  auto
 +   $ git config --global color.status auto
 +   
 +Identify yourself - set your name and your e-mail: ​
 +
 +   $ git config --global user.name "Slim Shady"
 +   $ git config --global user.email slim.shady@ctcc.no
 +   
 +Set the default mode for git push (current, matching or tracking): ​
 +
 +   $ git config --global push.default current
 +   
 +Disable fast-forward merges (read for instance [[http://​robey.lag.net/​2008/​07/​13/​git-for-the-real-world.html|here]]) ​
 +
 +   $ git config branch.master.mergeoptions "​--no-f
 +   
 +===== Recommended reading and viewing =====
 + 
 +  * [[http://​git-scm.com/​course/​svn.html|Here]] is a very nice collection of essential commands especially for people coming from the Subversion world: ​
 +  * [[http://​progit.org/​book/​|Here]] is probably the best book about Git, and it is online and free
 +  * [[http://​video.linux.com/​video/​1516|Here]] is a nice webcast - by the author of "Pro Git" - "Git in One Hour"
 +  * [[http://​gitready.com/​|Git Ready]] is also very nice
 +  * A very nice branching model with branching and merging examples is found [[http://​nvie.com/​posts/​a-successful-git-branching-model/​|here]] ​
 +  * And finally a [[http://​cheat.errtheblog.com/​s/​git|cheat sheet]]
 +  * The following man pages can be useful as well (especially when you are not online): ​
 +
 +   $ man gittutorial
 +   $ man gittutorial-2
 +   $ man gitcore-tutorial
 +   $ man gitworkflows
 +   $ man gitglossary
 +   
 +===== Basic work =====
 +
 +You can live a fulfilled life with the following few Git commands: ​
 +  * Clone the repository (checkout a working copy in Subversion speak): ​
 +
 +   $ git clone git@gitlab.com:​project_name.git
 +
 +  * Update your repository with changes from origin (svn update):
 +
 +   $ git pull
 +
 +  * Browse the history:
 +
 +   $ git log --topo-order --decorate [--oneline --graph]
 +
 +  * Add a file:
 +
 +   $ git add
 +
 +  * Move or rename:
 +
 +   $ git mv
 +
 +  * Remove:
 +
 +   $ git rm
 +
 +  * See which files are modified since last commit:
 +
 +   $ git status
 +
 +  * Browse the history and see which files have been modified:
 +
 +   $ git log --stat
 +
 +  * See your modifications:​
 +
 +   $ git diff
 +
 +  * Commit all uncommitted modifications:​
 +
 +   $ git commit -a
 +
 +  * Commit a specific file:
 +
 +   $ git commit ​
 +
 +  * Publish your changes to upstream (svn commit):
 +
 +   $ git push
 +
 +
how_to_work_with_git.1506938143.txt.gz ยท Last modified: 2017/10/02 11:55 by tsaue