Wiki source code of git

Version 169.1 by Kieran Kelleher on 2011/04/01 15:58

Hide last authors
Kieran Kelleher 169.1 1 = Got Git? If not, Get Git here =
2
3 Just pick the latest release for your Mac architecture here:
4 [[OS X dmg Installer>>http://code.google.com/p/git-osx-installer/]]
5
Kieran Kelleher 135.1 6 = Learning About git =
7
Kieran Kelleher 165.1 8 Start here:
Kieran Kelleher 135.1 9
Kieran Kelleher 165.1 10 * [[Excellent Concept Tutorial on Git>>http://www.eecs.harvard.edu/~~cduan/technical/git/]]
Kieran Kelleher 135.1 11
Kieran Kelleher 165.1 12 Have a Good Laugh here as Linus Torvalds Evangelizes git:
Kieran Kelleher 169.1 13 //this is more fun than learning, but gives you insight into the motivation behind git!//
Kieran Kelleher 135.1 14
Kieran Kelleher 165.1 15 * [[Linus Torvalds talks about git>>http://www.youtube.com/watch?v=4XpnKHJAok8]]
16
17 Learn the basics here:
18
19 * [[Everyday GIT With 20 Commands Or So>>http://www.kernel.org/pub/software/scm/git/docs/everyday.html]]
20 * [[Free Online Pro Git book>>http://progit.org/book/]]
21
22 Get the Detailed Reference Materials Here:
23
24 * [[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]]
25 * [[Git Reference>>http://gitref.org/index.html]]
26
Kieran Kelleher 135.1 27 = Git Goodies =
28
Kieran Kelleher 155.1 29 === Git Bash Completion ===
30
31 This is really an absolute necessity and a **huge** productivity improvement. Basically you need the bash completion script from the source tarball and use your shell profile to include it whenever you open a shell. See the **Auto-Completion** section on this page:
32 [[Git Bash Auto-Completion>>http://progit.org/book/ch2-7.html]]
33
Kieran Kelleher 137.1 34 === GitX git GUI ===
35
36 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.
Kieran Kelleher 135.1 37 [[GitX Home Page>>http://gitx.frim.nl/]]
38
Kieran Kelleher 137.1 39 === Open in GitX ===
Kieran Kelleher 135.1 40
41 [[Open In GitX Finder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]]
42
43 == Git Tower ==
44
45 For those of you who just get panic attacks at the thought of using the Terminal, there is a commercial app for that:
46 [[Git Tower>>http://www.git-tower.com/]]
47
Kieran Kelleher 169.1 48 I use Tower (bought it), but only for committing and fixing merge conflicts. I think Tower misses quite a bit of the flagship feature of GIT: branches. You can't see a branch tree graphically, like you can with gitX or even the command line (git log ---graph ---color, IIRC). But it's cool for committing. For everything else I use command line.
49 - Miguel Arroz
50
Kieran Kelleher 135.1 51 = Using git locally on a Subversion Working Copy =
Kieran Kelleher 137.1 52
53 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!
54
Kieran Kelleher 153.1 55 There is a git-svn tool (type man git-svn in the terminal for details), but that adds yet another tool into the mix that you have to learn. So while you could use it and YMMV for projects tht are going to be on svn forever, I recommend you 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, especially if you are typically working on one particular branch of the remote svn repository.
Kieran Kelleher 137.1 56
57 = I want to learn git before I switch from Subversion =
58
59 (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 ;-) )
60 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:
61
62 [[**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]]
63
Kieran Kelleher 153.1 64 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. Unless you want to use git locally to switch between svn branches, I don't recommend it. Use the **git+svn** approach outlined in above blog post instead.
Kieran Kelleher 137.1 65
66 Once you start using git, it becomes addictive ....... you can never go back ...... really, it's that good ...... and it is not hard.
67
68 Some tips for Eclipse setup and general workflow when using git locally on svn working copies,
69
Kieran Kelleher 153.1 70 * check out the entire svn branch that you work on using the command line, then LINK (import no copy) the projects you want in your workspace using the Subclipse import tool, and
Kieran Kelleher 137.1 71 * Do your git operations (status, staging, commit, diff, branching, checkouts, rebase and merge using the terminal). git on the terminal is efficient... honest.
72 * Do all your local work and cimmits on branches other than the master branch.
73 * Switch to master branch to update from svn and commit those svn updates on the master branch.
74 * Merge your working branch(es) with or rebase your working branch(es) from the master and just keep on working.
75 * Switch to master branch before synchronizing with remote svn repo.
76 * 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.
77
Kieran Kelleher 155.1 78 {{code title="Mechanics of an svn update operation on a git-managed svn working copy"}}
Kieran Kelleher 137.1 79
Kieran Kelleher 153.1 80
Kieran Kelleher 137.1 81 # Assume you are currently on a working branch. Verify this and check for uncommitted changes.
82 git status
83
Kieran Kelleher 153.1 84 # Either commit your local changes to your working branch
85 # using 'git add' + 'git commit', or temporarily stash
86 # them using 'git stash'
Kieran Kelleher 137.1 87 git stash
88
89 # Switch to master branch
90 git checkout master
91
Kieran Kelleher 153.1 92 # Ensure there are no changes either from an svn perspective
93 # or a git perspective on the master branch.
Kieran Kelleher 137.1 94 git status
95 svn status
96
97 # Update the master branch from remote svn repo
98 svn update
99
100 # Commit those updates to git repo
101 git commit -a -m "updated from remote svn repo"
102
103 # Switch to your working branch
104 git checkout workingbranch
105
106 # Merge or rebase your working branch off of the updated master.
107 # This rewinds your branch commits back to the common commit ancestor
108 # shared between your working branch and the master branch. Then it
109 # applies the master branch commits (the svn updates) so that this
110 # working branch becomes identical to the master. After that it 'replays'
111 # your working branch commits on top of the updated branch.
112 # This ensures a clean linear progression. Rebasing is a very cool feature of git.
113 rebase master
114
115 # Now if you stashed uncommitted changes earlier, you can pop them back into
116 # the working copy
117 git stash pop
118
Kieran Kelleher 153.1 119 {{/code}}
Kieran Kelleher 155.1 120
121 {{code title="Mechanics of an svn commit operation from a git-managed svn working copy"}}
122
123 # First perform an svn update as outlined above in the previous section
124
125 # Switch to the master branch
126 git checkout master
127
128 # Merge your working branch with the master
129 git merge workingbranch
130
131 # Use svn status, svn add and svn commit to commit your changes to the remote svn repository
132
133 # Switch back to your workingbranch and get back to work.
134
135
136 {{/code}}