Changes for page Getting Started with Git
Last modified by Bastian Triller on 2013/05/21 17:24
From version 136.1
edited by Kieran Kelleher
on 2011/03/21 14:54
on 2011/03/21 14:54
Change comment:
There is no comment for this version
To version 154.1
edited by Kieran Kelleher
on 2011/03/21 18:46
on 2011/03/21 18:46
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -3,19 +3,20 @@ 3 3 [[Free Online Pro Git book>>http://progit.org/book/]] 4 4 [[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]] 5 5 [[Git Reference>>http://gitref.org/index.html]] 6 +[[Linus Torvalds talks about git>>http://www.youtube.com/watch?v=4XpnKHJAok8]] 6 6 7 7 = Install Git = 8 8 9 -[[OS X dmg Installerhttp:code.google.compgit-osx-installer]] 10 +[[OS X dmg Installer>>http://code.google.com/p/git-osx-installer/]] 10 10 11 11 = Git Goodies = 12 12 13 -== GitX git GUI == 14 +=== GitX git GUI === 14 14 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 commiting. 16 +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 16 [[GitX Home Page>>http://gitx.frim.nl/]] 17 17 18 -== Open in GitX == 19 +=== Open in GitX === 19 19 20 20 [[Open In GitX Finder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]] 21 21 ... ... @@ -25,3 +25,71 @@ 25 25 [[Git Tower>>http://www.git-tower.com/]] 26 26 27 27 = Using git locally on a Subversion Working Copy = 29 + 30 +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! 31 + 32 +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. 33 + 34 += I want to learn git before I switch from Subversion = 35 + 36 +(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 ;-) ) 37 +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: 38 + 39 +[[**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]] 40 + 41 +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. 42 + 43 +Once you start using git, it becomes addictive ....... you can never go back ...... really, it's that good ...... and it is not hard. 44 + 45 +Some tips for Eclipse setup and general workflow when using git locally on svn working copies, 46 + 47 +* 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 48 +* Do your git operations (status, staging, commit, diff, branching, checkouts, rebase and merge using the terminal). git on the terminal is efficient... honest. 49 +* Do all your local work and cimmits on branches other than the master branch. 50 +* Switch to master branch to update from svn and commit those svn updates on the master branch. 51 +* Merge your working branch(es) with or rebase your working branch(es) from the master and just keep on working. 52 +* Switch to master branch before synchronizing with remote svn repo. 53 +* 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. 54 + 55 +{{code title="Anatomony of an svn update operation on a git-managed svn working copy"}} 56 + 57 + 58 +# Assume you are currently on a working branch. Verify this and check for uncommitted changes. 59 +git status 60 + 61 +# Either commit your local changes to your working branch 62 +# using 'git add' + 'git commit', or temporarily stash 63 +# them using 'git stash' 64 +git stash 65 + 66 +# Switch to master branch 67 +git checkout master 68 + 69 +# Ensure there are no changes either from an svn perspective 70 +# or a git perspective on the master branch. 71 +git status 72 +svn status 73 + 74 +# Update the master branch from remote svn repo 75 +svn update 76 + 77 +# Commit those updates to git repo 78 +git commit -a -m "updated from remote svn repo" 79 + 80 +# Switch to your working branch 81 +git checkout workingbranch 82 + 83 +# Merge or rebase your working branch off of the updated master. 84 +# This rewinds your branch commits back to the common commit ancestor 85 +# shared between your working branch and the master branch. Then it 86 +# applies the master branch commits (the svn updates) so that this 87 +# working branch becomes identical to the master. After that it 'replays' 88 +# your working branch commits on top of the updated branch. 89 +# This ensures a clean linear progression. Rebasing is a very cool feature of git. 90 +rebase master 91 + 92 +# Now if you stashed uncommitted changes earlier, you can pop them back into 93 +# the working copy 94 +git stash pop 95 + 96 +{{/code}}