Wiki source code of git

Version 101.1 by Kieran Kelleher on 2011/03/21 16:01

Hide last authors
Kieran Kelleher 99.1 1 = Learning About git =
Kieran Kelleher 36.1 2
Kieran Kelleher 99.1 3 [[Free Online Pro Git book>>http://progit.org/book/]]
4 [[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]]
5 [[Git Reference>>http://gitref.org/index.html]]
Kieran Kelleher 36.1 6
Kieran Kelleher 99.1 7 = Install Git =
Kieran Kelleher 36.1 8
Kieran Kelleher 99.1 9 [[OS X dmg Installer>>http://code.google.com/p/git-osx-installer/]]
Kieran Kelleher 36.1 10
Kieran Kelleher 99.1 11 = Git Goodies =
Kieran Kelleher 36.1 12
David Avendasora 77.1 13 === GitX git GUI ===
Kieran Kelleher 36.1 14
David Avendasora 77.1 15 GitX is an awesome FREE history viewer made for OS X. It is a better way to visualize your branch and commit history of your git repository. However, power users (aka "cool kids") will probably only use it for history viewing while they continue to use the terminal command line for checkouts, branching, staging, rebasing and committing.
16 [[GitX Home Page>>http://gitx.frim.nl/]]
Kieran Kelleher 36.1 17
Kieran Kelleher 66.1 18 === Open in GitX ===
Kieran Kelleher 36.1 19
Kieran Kelleher 66.1 20 [[Open In GitX Finder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]]
Kieran Kelleher 36.1 21
Kieran Kelleher 99.1 22 == Git Tower ==
Kieran Kelleher 36.1 23
Kieran Kelleher 99.1 24 For those of you who just get panic attacks at the thought of using the Terminal, there is a commercial app for that:
25 [[Git Tower>>http://www.git-tower.com/]]
Kieran Kelleher 36.1 26
Kieran Kelleher 99.1 27 = Using git locally on a Subversion Working Copy =
Kieran Kelleher 36.1 28
Kieran Kelleher 99.1 29 OK, so you are addicted to git, and now you have to work on a team project that is hosted in a remote subversion repository ... and it is making you depressed :-(. Well, you can use manage your local svn working copy using git and be happy again!
Kieran Kelleher 36.1 30
Kieran Kelleher 101.1 31 Don't use the git-svn tool, just use the [[git+svn protocol>>http://www.lostechies.com/blogs/derickbailey/archive/2010/02/03/branch-per-feature-how-i-manage-subversion-with-git-branches.aspx]] instead.
Kieran Kelleher 36.1 32
Kieran Kelleher 99.1 33 = I want to learn git before I switch from Subversion =
Kieran Kelleher 36.1 34
Kieran Kelleher 99.1 35 (This kind of repeats some of the previous section, but that's on purpose so we can condition you brain to start using git right now ;-) )
36 Even while you are working with svn repositories, you can start learning and taking advantage of git right now by making your local svn working copy an actual local git repository. The idea is to use the appropriate ignore feature of each SCM system to ignore the hidden files of the other system. The concept is described here:
Kieran Kelleher 36.1 37
Kieran Kelleher 99.1 38 [[**git+svn** Working Protocol>>http://www.lostechies.com/blogs/derickbailey/archive/2010/02/03/branch-per-feature-how-i-manage-subversion-with-git-branches.aspx]]
Kieran Kelleher 36.1 39
Kieran Kelleher 101.1 40 When you first learn about git and you google "git svn" you will learn about a command line tool git-svn which works directly with remote svn repos, however my advice is don't use git-svn. Use the **git+svn** approach outlined in above blog post instead.
Kieran Kelleher 36.1 41
Kieran Kelleher 99.1 42 Once you start using git, it becomes addictive ....... you can never go back ...... really, it's that good ...... and it is not hard.
Kieran Kelleher 36.1 43
Kieran Kelleher 99.1 44 Some tips for Eclipse setup and general workflow when using git locally on svn working copies,
Kieran Kelleher 36.1 45
Kieran Kelleher 101.1 46 * check out the entire svn branch on the command line, then LINK (import no copy) the projects you want in your workspace using the Subclipse import tool, and
Kieran Kelleher 99.1 47 * Do your git operations (status, staging, commit, diff, branching, checkouts, rebase and merge using the terminal). git on the terminal is efficient... honest.
48 * Do all your local work and cimmits on branches other than the master branch.
49 * Switch to master branch to update from svn and commit those svn updates on the master branch.
50 * Merge your working branch(es) with or rebase your working branch(es) from the master and just keep on working.
51 * Switch to master branch before synchronizing with remote svn repo.
52 * You can use ##git stash## to temporarily put aside your uncommitted changes before doing an svn update. Then use ##git stash pop## to replay those uncommitted changes onto the working copy.
Kieran Kelleher 36.1 53
Kieran Kelleher 99.1 54 {{code title="Anatomony of an svn update operation on a git-managed svn working copy"}}
Kieran Kelleher 36.1 55
56
Kieran Kelleher 99.1 57 # Assume you are currently on a working branch. Verify this and check for uncommitted changes.
58 git status
Kieran Kelleher 97.1 59
Kieran Kelleher 99.1 60 # Either commit your local changes to your working branch
61 # using 'git add' + 'git commit', or temporarily stash
62 # them using 'git stash'
63 git stash
Kieran Kelleher 97.1 64
Kieran Kelleher 99.1 65 # Switch to master branch
66 git checkout master
Kieran Kelleher 97.1 67
Kieran Kelleher 99.1 68 # Ensure there are no changes either from an svn perspective
69 # or a git perspective on the master branch.
70 git status
71 svn status
Kieran Kelleher 97.1 72
Kieran Kelleher 99.1 73 # Update the master branch from remote svn repo
74 svn update
Ray Kiddy 93.1 75
Kieran Kelleher 99.1 76 # Commit those updates to git repo
77 git commit -a -m "updated from remote svn repo"
Ray Kiddy 93.1 78
Kieran Kelleher 99.1 79 # Switch to your working branch
80 git checkout workingbranch
Ray Kiddy 93.1 81
Kieran Kelleher 99.1 82 # Merge or rebase your working branch off of the updated master.
83 # This rewinds your branch commits back to the common commit ancestor
84 # shared between your working branch and the master branch. Then it
85 # applies the master branch commits (the svn updates) so that this
86 # working branch becomes identical to the master. After that it 'replays'
87 # your working branch commits on top of the updated branch.
88 # This ensures a clean linear progression. Rebasing is a very cool feature of git.
89 rebase master
Ray Kiddy 93.1 90
Kieran Kelleher 99.1 91 # Now if you stashed uncommitted changes earlier, you can pop them back into
92 # the working copy
93 git stash pop
Kieran Kelleher 36.1 94
95 {{/code}}