Changes for page Getting Started with Git
Last modified by Bastian Triller on 2013/05/21 17:24
From version 182.1
edited by David Avendasora
on 2011/04/29 15:44
on 2011/04/29 15:44
Change comment:
There is no comment for this version
To version 164.1
edited by Kieran Kelleher
on 2011/03/29 16:24
on 2011/03/29 16:24
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - GettingStarted with Git1 +git - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. avendasora1 +XWiki.kieran - Content
-
... ... @@ -1,98 +1,119 @@ 1 -= Got Git?No? GetGit =1 += Learning About git = 2 2 3 -* Official Download Site: [[http://git-scm.com/download]] 4 -* Direct Download Links: 5 -** MacOS X [[.dmg Binary Installers>>http://code.google.com/p/git-osx-installer/]] 6 -** Microsoft Windows [[.exe Binary Installers>>http://code.google.com/p/msysgit/]] 3 +[[Excellent Concept Tutorial on Git>>http://www.eecs.harvard.edu/~~cduan/technical/git/]] 4 +[[Free Online Pro Git book>>http://progit.org/book/]] 5 +[[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]] 6 +[[Git Reference>>http://gitref.org/index.html]] 7 +[[Linus Torvalds talks about git>>http://www.youtube.com/watch?v=4XpnKHJAok8]] 7 7 8 -= LearnAbout Git =9 += Install Git = 9 9 10 -* Learn the concepts. 11 -** [[This>>http://www.eecs.harvard.edu/~~cduan/technical/git/]] is an excellent tutorial on the basic concepts behind Git 11 +[[OS X dmg Installer>>http://code.google.com/p/git-osx-installer/]] 12 12 13 -* Learn the basics. 14 -** [[Everyday GIT With 20 Commands Or So>>http://www.kernel.org/pub/software/scm/git/docs/everyday.html]] 15 -** [[Free Online Pro Git book>>http://progit.org/book/]] 13 += Git Goodies = 16 16 17 -* Get familiar with the reference materials available online 18 -** Official [[Git Documentation>>http://git-scm.com/documentation]] Site 19 -** Official [[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]] 20 -** [[Git Reference>>http://gitref.org/index.html]] 15 +=== Git Bash Completion === 21 21 22 -* Git Cheat Sheets 23 -** [[http://cheat.errtheblog.com/s/git/]] 24 -** [[http://ktown.kde.org/%7Ezrusin/git/git-cheat-sheet-medium.png]] 17 +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: 18 +[[Git Bash Auto-Completion>>http://progit.org/book/ch2-7.html]] 25 25 26 -* [[Linus Torvalds talks about git>>http://www.youtube.com/watch?v=4XpnKHJAok8]] 27 -Have a Good Laugh here as Linus Torvalds Evangelizes git. //NOTE: This isn't really learning, but it is way more fun and gives you insight into the motivation behind git.// 20 +=== GitX git GUI === 28 28 29 -= Get Started with Project Wonder = 22 +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. 23 +[[GitX Home Page>>http://gitx.frim.nl/]] 30 30 31 - Thebest way to learn a new concept is to actually useit, andwhat better way than to do somethingpractical like clone (checkout)the Project Wonder source code25 +=== Open in GitX === 32 32 33 - *[[DownloadingWonder>>http://wiki.objectstyle.org/confluence/display/WONDER/Getting+the+Wonder+Source+Code]] WikiPage27 +[[Open In GitX Finder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]] 34 34 35 -= UseGit with a SubversionProject=29 +== Git Tower == 36 36 37 -OK, so you want to use Git but you are working on a team project that is hosted in a subversion repository ... and it is making you depressed :-( . Well, you can still use Git to manage your local SVN working copy and be happy again 31 +For those of you who just get panic attacks at the thought of using the Terminal, there is a commercial app for that: 32 +[[Git Tower>>http://www.git-tower.com/]] 38 38 39 - Irecommendyou just use the [[git+svnprotocol>>http://www.lostechies.com/blogs/derickbailey/archive/2010/02/03/branch-per-feature-how-i-manage-subversion-with-git-branches.aspx]].34 += Using git locally on a Subversion Working Copy = 40 40 41 - =GitGoodiesforWebObjectsDevelopers=36 +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! 42 42 43 -This is a listof tools that otherWebObjectsdevelopers havefoundto behelpful.It'snotacomprehensivelist, andif youfindthingsnotlistedherepleaseaddthem38 +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. 44 44 45 -= ==EGit ===40 += I want to learn git before I switch from Subversion = 46 46 47 -EGit is a plugin for Eclipse 3.6. It's not as good as Tower or GitX, but you can use it for most tasks (add, commit, push, pull). 42 +(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 ;-) ) 43 +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: 48 48 49 -* [[EGit/Git For Eclipse Users>>http://wiki.eclipse.org/EGit/Git_For_Eclipse_Users]] 50 -* [[User Guide>>http://wiki.eclipse.org/EGit/User_Guide]] 51 -* Installation 52 -*1. In Eclipse, select //Help > Install New Sofware...// 53 -*1. Select the "Helios" download site from the Work with: combo box 54 -*1. Expand the "Collaboration" group 55 -*1. Select the EGit plugin, click Next 56 -*1. Complete the install process and agree to the license, etc. 57 -*1. Restart Eclipse. 45 +[[**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]] 58 58 59 - ===GitBashCompletion===47 +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. 60 60 61 -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: 62 -[[Git Bash Auto-Completion>>http://progit.org/book/ch2-7.html]] 49 +Once you start using git, it becomes addictive ....... you can never go back ...... really, it's that good ...... and it is not hard. 63 63 64 - ===GitXgitGUI===51 +Some tips for Eclipse setup and general workflow when using git locally on svn working copies, 65 65 66 -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. 67 -[[GitX Home Page>>http://gitx.frim.nl/]] 53 +* 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 54 +* Do your git operations (status, staging, commit, diff, branching, checkouts, rebase and merge using the terminal). git on the terminal is efficient... honest. 55 +* Do all your local work and cimmits on branches other than the master branch. 56 +* Switch to master branch to update from svn and commit those svn updates on the master branch. 57 +* Merge your working branch(es) with or rebase your working branch(es) from the master and just keep on working. 58 +* Switch to master branch before synchronizing with remote svn repo. 59 +* 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. 68 68 69 -= ==OpeninGitX===61 +{{code title="Mechanics of an svn update operation on a git-managed svn working copy"}} 70 70 71 -[[Open In GitX Finder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]] 72 72 73 -=== Git Tower === 64 +# Assume you are currently on a working branch. Verify this and check for uncommitted changes. 65 +git status 74 74 75 -[[Git Tower>>http://www.git-tower.com/]] is a commerical app for those of you who just get panic attacks at the thought of using the Terminal. 67 +# Either commit your local changes to your working branch 68 +# using 'git add' + 'git commit', or temporarily stash 69 +# them using 'git stash' 70 +git stash 76 76 77 - Iuse Tower (boughtit), but only forcommitting and fixing merge conflicts. I thinkTowermisses quiteabit of the flagship featureof GIT: branches.You can't see abranchtree 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.78 - MiguelArroz72 +# Switch to master branch 73 +git checkout master 79 79 80 -= Unique Git Concepts = 75 +# Ensure there are no changes either from an svn perspective 76 +# or a git perspective on the master branch. 77 +git status 78 +svn status 81 81 82 -=== Rebasing === 80 +# Update the master branch from remote svn repo 81 +svn update 83 83 84 -Rebasing is unique to git. There is no counterpart in Subversion. 83 +# Commit those updates to git repo 84 +git commit -a -m "updated from remote svn repo" 85 85 86 -Rebasing cuts down on the spaghetti history of merging and helps to keep history nice and linear. 86 +# Switch to your working branch 87 +git checkout workingbranch 87 87 88 -Conceptually, when I rebase my current branch A on another branch B, git removes all my branch A commits back to the common ancestor of A and B, stashes those commits away temporarily, moves the head of the current branch A to the tip of the other branch B, and then re-applys all my stashed commits as **new commit** patches to my branch B. 89 +# Merge or rebase your working branch off of the updated master. 90 +# This rewinds your branch commits back to the common commit ancestor 91 +# shared between your working branch and the master branch. Then it 92 +# applies the master branch commits (the svn updates) so that this 93 +# working branch becomes identical to the master. After that it 'replays' 94 +# your working branch commits on top of the updated branch. 95 +# This ensures a clean linear progression. Rebasing is a very cool feature of git. 96 +rebase master 89 89 90 -However before using it on work that is shared with others you MUST follow the these rules, otherwise you will screw everyone else on the project. 98 +# Now if you stashed uncommitted changes earlier, you can pop them back into 99 +# the working copy 100 +git stash pop 91 91 92 -* If you don't understand rebasing, don't use it You can learn more about it here: 93 -** [[http://progit.org/book/ch3-6.html]] 94 -** [[http://www.eecs.harvard.edu/~~cduan/technical/git/git-5.shtml]] 95 -** [[http://book.git-scm.com/4_rebasing.html]] 96 -** [[http://blip.tv/file/4094727]] 97 -* Use rebase only on **private** branches 98 -* Use rebase only for commits that have **not been pushed** to a remote repo 102 +{{/code}} 103 + 104 +{{code title="Mechanics of an svn commit operation from a git-managed svn working copy"}} 105 + 106 +# First perform an svn update as outlined above in the previous section 107 + 108 +# Switch to the master branch 109 +git checkout master 110 + 111 +# Merge your working branch with the master 112 +git merge workingbranch 113 + 114 +# Use svn status, svn add and svn commit to commit your changes to the remote svn repository 115 + 116 +# Switch back to your workingbranch and get back to work. 117 + 118 + 119 +{{/code}}