Changes for page Getting Started with Git
Last modified by Bastian Triller on 2013/05/21 17:24
From version 66.1
edited by Kieran Kelleher
on 2012/01/03 09:54
on 2012/01/03 09:54
Change comment:
There is no comment for this version
To version 36.1
edited by Kieran Kelleher
on 2011/04/06 19:17
on 2011/04/06 19:17
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 - GettingStarted with Git1 +git - Content
-
... ... @@ -1,163 +1,141 @@ 1 - {{toc}}{{/toc}}1 += Got Git? If not, Get Git here = 2 2 3 -= Got Git? No? Get Git = 3 +Just pick the latest release for your Mac architecture here: 4 +[[OS X dmg Installer>>http://code.google.com/p/git-osx-installer/]] 4 4 5 -* Official Download Site: [[http://git-scm.com/download]] 6 -* Direct Download Links: 7 -** MacOS X [[.dmg Binary Installers>>http://code.google.com/p/git-osx-installer/]] 8 -** Microsoft Windows [[.exe Binary Installers>>http://code.google.com/p/msysgit/]] 6 += Learning About git = 9 9 10 - {{infotitle="Gitis included withXCode4.x"}}8 +Start here: 11 11 12 - XCode4.xinstallsa copyof gitin /usr/bin/git10 +* [[Excellent Concept Tutorial on Git>>http://www.eecs.harvard.edu/~~cduan/technical/git/]] 13 13 14 -{{/info}} 12 +Have a Good Laugh here as Linus Torvalds Evangelizes git: 13 +//this is more fun than learning, but gives you insight into the motivation behind git!// 15 15 16 -= Learn About Git = 17 - 18 -* Learn the concepts. 19 -** Scott Chacon (of GitHub) Video Intro [[http://www.youtube.com/watch?v=ZDR433b0HJY]] 20 -** [[This>>http://www.eecs.harvard.edu/~~cduan/technical/git/]] is an excellent tutorial on the basic concepts behind Git 21 -** [[Git for Computer Scientists>>http://eagain.net/articles/git-for-computer-scientists/]] gives another good view on the underlying concepts 22 -* Learn the basics. 23 -** [[Everyday GIT With 20 Commands Or So>>http://www.kernel.org/pub/software/scm/git/docs/everyday.html]] 24 -** [[Free Online Pro Git book>>http://progit.org/book/]] 25 -*** There is even a free epub version for your iPad/iPhone [[https://github.s3.amazonaws.com/media/progit.epub]] 26 - 27 -* Get familiar with the reference materials available online 28 -** [[Git Community Book>>http://book.git-scm.com/]] 29 -** Official [[Git Documentation>>http://git-scm.com/documentation]] Site 30 -** Official [[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]] 31 -** [[Git Reference>>http://gitref.org/index.html]] 32 - 33 -* Git Cheat Sheets 34 -** [[http://cheat.errtheblog.com/s/git/]] 35 -** [[http://ktown.kde.org/%7Ezrusin/git/git-cheat-sheet-medium.png]] 36 - 37 37 * [[Linus Torvalds talks about git>>http://www.youtube.com/watch?v=4XpnKHJAok8]] 38 -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.// 39 39 40 - = Get StartedwithProjectWonder=17 +Learn the basics here: 41 41 42 -The best way to learn a new concept is to actually use it, and what better way than to do something practical like clone the Project Wonder git source code repository 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/]] 43 43 44 - * [[Downloading Wonder>>http://wiki.objectstyle.org/confluence/display/WONDER/Getting+the+Wonder+Source+Code]] Wiki Page22 +Get the Detailed Reference Materials Here: 45 45 46 -= Use Git with a Subversion Project = 24 +* [[Git User Manual>>http://www.kernel.org/pub/software/scm/git/docs/user-manual.html]] 25 +* [[Git Reference>>http://gitref.org/index.html]] 47 47 48 - OK, so you want to useGitbut you are working on a team project that is hosted inasubversion repository... and it is making you depressed :-( . Well, you can still use Git to manage your localSVN working copy and be almosthappy again (Either way, you won't be100% happy unlessthe repository is a git one.)27 +Git Cheat Sheets 49 49 50 -There are a couple ways of doing this. Two of them are: 29 +* [[http://cheat.errtheblog.com/s/git/]] 30 +* [[http://ktown.kde.org/%7Ezrusin/git/git-cheat-sheet-medium.png]] 51 51 52 -* Follow these [[Instructions>>http://www.lostechies.com/blogs/derickbailey/archive/2010/02/03/branch-per-feature-how-i-manage-subversion-with-git-branches.aspx]] to manually set up the integration. 53 -* Use [[SourceTree>>http://itunes.apple.com/us/app/sourcetree-git-hg/id411678673?mt=12]] which can clone your SVN repository locally as a full Git repository including all historical SVN commits and their metadata. 32 += Git Goodies = 54 54 55 -= Git Goodies for WebObjects Developers = 56 - 57 -This is a list of tools that other WebObjects developers have found to be helpful. It's not a comprehensive list, and if you find things not listed here please add them 58 - 59 -=== EGit === 60 - 61 -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). 62 - 63 -* [[EGit/Git For Eclipse Users>>http://wiki.eclipse.org/EGit/Git_For_Eclipse_Users]] 64 -* [[User Guide>>http://wiki.eclipse.org/EGit/User_Guide]] 65 -* Installation 66 -*1. In Eclipse, select //Help > Install New Sofware...// 67 -*1. Select the "Helios" download site from the Work with: combo box 68 -*1. Expand the "Collaboration" group 69 -*1. Select the EGit plugin, click Next 70 -*1. Complete the install process and agree to the license, etc. 71 -*1. Restart Eclipse. 72 - 73 73 === Git Bash Completion === 74 74 75 75 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: 76 76 [[Git Bash Auto-Completion>>http://progit.org/book/ch2-7.html]] 77 77 78 -=== SourceTree by Atlassian===39 +=== GitX git GUI === 79 79 80 -SourceTree is a free Git/Mercurial GUI for OS X. A key feature is that it can use git-svn to "Clone" a SVN repository into a standard Git repository with your full SVN commit history and maintains a link back to the SVN repository. This allows you to easily use Git locally for development but still do your final commits to SVN. 41 +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. 42 +[[GitX Home Page>>http://gitx.frim.nl/]] 81 81 82 -* [[SourceTree on AppStore>>http://itunes.apple.com/us/app/sourcetree-git-hg/id411678673?mt=12]] 83 -* [[SourceTree Home Page>>http://www.sourcetreeapp.com/]] 44 +=== Open in GitX === 84 84 85 - ===GitX(L)gitGUI===46 +[[Open In GitX Finder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]] 86 86 87 -While most (if not all) Git GUI apps will never be able to emulate all the intricate functionality of Git, one advantage of a GUI app is more convenient and faster browsing/visualization of history and inter-relationships of branches. While development on the original open source GitX.app has waned, this fork of the original has continued to mature into a nice Git client, and is useful for common every day Git operations. 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. 88 -[[GitX (L) Home Page>>http://gitx.laullon.com/]] 48 +== Git Tower == 89 89 90 -Note this app replace the original [[GitX>>http://gitx.frim.nl/]] by Pieter de Bie. 50 +For those of you who just get panic attacks at the thought of using the Terminal, there is a commercial app for that: 51 +[[Git Tower>>http://www.git-tower.com/]] 91 91 92 -=== Open in GitX === 53 +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. 54 +- Miguel Arroz 93 93 94 - [[OpenInGitXFinder Droplet>>http://code.google.com/p/git-osx-installer/wiki/OpenInGitX]]56 += Using git locally on a Subversion Working Copy = 95 95 96 - ===GitTower===58 +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! 97 97 98 - [[GitTower>>http://www.git-tower.com/]]is acommerical appfor those of youwhojustgetpanicattackst theof using theTerminal.60 +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. 99 99 100 -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. 101 - Miguel Arroz 62 += I want to learn git before I switch from Subversion = 102 102 103 -= Unique Git Concepts = 64 +(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 ;-) ) 65 +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: 104 104 105 - ===Rebasing===67 +[[**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]] 106 106 107 - Rebasing is unique to git.There isnocounterpart inSubversion.69 +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. 108 108 109 - Rebasingcutsdownon thepaghettihistoryofmergingandhelpsto keephistoryniceandlinear.71 +Once you start using git, it becomes addictive ....... you can never go back ...... really, it's that good ...... and it is not hard. 110 110 111 - Conceptually, when I rebasemy currentbranch A on another branch B, git removesall my branchAcommitsback to thecommon ancestorof AandB, stashes thosecommitsawaytemporarily, movesthehead of the currentbranch A to the tip oftheother branch B,and then re-applys all mystashed commitsas**newcommit**patchesto my branch B.73 +Some tips for Eclipse setup and general workflow when using git locally on svn working copies, 112 112 113 -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. 75 +* 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 76 +* Do your git operations (status, staging, commit, diff, branching, checkouts, rebase and merge using the terminal). git on the terminal is efficient... honest. 77 +* Do all your local work and cimmits on branches other than the master branch. 78 +* Switch to master branch to update from svn and commit those svn updates on the master branch. 79 +* Merge your working branch(es) with or rebase your working branch(es) from the master and just keep on working. 80 +* Switch to master branch before synchronizing with remote svn repo. 81 +* 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. 114 114 115 -* If you don't understand rebasing, don't use it You can learn more about it here: 116 -** [[http://progit.org/book/ch3-6.html]] 117 -** [[http://www.eecs.harvard.edu/~~cduan/technical/git/git-5.shtml]] 118 -** [[http://book.git-scm.com/4_rebasing.html]] 119 -** [[http://blip.tv/file/4094727]] 120 -* Use rebase only on **private** branches 121 -* Use rebase only for commits that have **not been pushed** to a remote repo 83 +{{code title="Mechanics of an svn update operation on a git-managed svn working copy"}} 122 122 123 -=== Push/Pull vs Commit/Update === 124 124 125 -It may be helpful to separate "push/pull" in your mind from "commit/update". Say that I have a bunch of changes that I want to --commit to Wonder-- share with the community. I am not going to push my changes. I am going to check in my changes to my repository (either a clone or a fork) and then push from my repository or generate a pull request from my repository. My repository should be fully checked in before I do this. 86 +# Assume you are currently on a working branch. Verify this and check for uncommitted changes. 87 +git status 126 126 127 -Say that I do not want to check in all of the changes I am looking at. The answer seems to be that you create a branch, take the changes you want to share, commit them and then share from that branch. And, again, before one generates the pull request or does the push, the branch should be clean and all changes in it should be committed. 89 +# Either commit your local changes to your working branch 90 +# using 'git add' + 'git commit', or temporarily stash 91 +# them using 'git stash' 92 +git stash 128 128 129 -What if one wants to generate a pull request the origin and also push to a fork? You would do this if you were not a Wonder committer but wanted to share code. You organize your changes in your local repository/branch and, from the clean repository or branch, generate the pull request and, separately, push the changes to your fork. 94 +# Switch to master branch 95 +git checkout master 130 130 131 -=== Testing a Pull-Request === 97 +# Ensure there are no changes either from an svn perspective 98 +# or a git perspective on the master branch. 99 +git status 100 +svn status 132 132 133 -It may not be obvious how to do this. If one is a committer, there is a button one can push to automatically accept a pull-request. But is this really a safe thing to do? But how can you get the diffs being suggested? It seems more complicated than it needs to be to merge the branch the pull-request was made from. One can actually use a URL that specifies just the diff. If the pull-request is at [[https://github.com/projectwonder/wonder/pull/43]], one can do: 102 +# Update the master branch from remote svn repo 103 +svn update 134 134 135 -{{code}} 136 -curl 'https://github.com/projectwonder/wonder/pull/43.patch' | git am 137 -{{/code}} 105 +# Commit those updates to git repo 106 +git commit -a -m "updated from remote svn repo" 138 138 139 -The curl fetches the diff. Take off the "git am" to just see the diffs. The "git am" merges the diffs. Then you may build and test the pull-request. A normal push will push the code into the repository. 108 +# Switch to your working branch 109 +git checkout workingbranch 140 140 141 -=== How Easy Are Branches? === 111 +# Merge or rebase your working branch off of the updated master. 112 +# This rewinds your branch commits back to the common commit ancestor 113 +# shared between your working branch and the master branch. Then it 114 +# applies the master branch commits (the svn updates) so that this 115 +# working branch becomes identical to the master. After that it 'replays' 116 +# your working branch commits on top of the updated branch. 117 +# This ensures a clean linear progression. Rebasing is a very cool feature of git. 118 +rebase master 142 142 143 -It may be helpful to realize this. You should become comfortable with branching. In svn, branching is hard but it is not hard in git. If you have a thought, mull over that thought for a few minutes and jot something down, you have done enough to justify a branch and the branch will be not much harder than finding the post-its on your desk, and perhaps easier. Think about when you would have created a branch in svn. For that amount of work and to establish that level of separation, in git you would create a fork, or create a new repository. 120 +# Now if you stashed uncommitted changes earlier, you can pop them back into 121 +# the working copy 122 +git stash pop 144 144 145 - Might you end up with too many branches? Perhaps. How messy is yourdesk? If you are a clean-desk person, you will probably not have too many branches. You will organize and combine your branches. You will rebase your branches. You may delete your branches. After all, you had the thought. You can write the code again. If it is too distracting to keep the branch relevant, tuck the thought into the back of your head, delete the branch, let it go and move on. If you are a messy-desk person, you will probably have lots of branches. It would probably be a good thing to clean up, merge and rebase your branches before you try to share your changes. But that is obvious. Nobody wants to see how messy your desk is.124 +{{/code}} 146 146 147 - Keep in mind that the difficult partof what youdo should be the thinking. Gitmakes iteasy to organize andshareyourthoughtsas branches.Your local copiesmay bemessy or not.They are the thoughts you havein your head andlots ofthosethoughtswill stay there and never see the light ofdayand that isok. But whenyou have clarified your thoughts,git will make it easy toshare them.126 +{{code title="Mechanics of an svn commit operation from a git-managed svn working copy"}} 148 148 149 - ===FindingtheListof AllGitCommands===128 +# First perform an svn update as outlined above in the previous section 150 150 151 -The "git help" command gives one the list of commonly used git commands. How does one find the others, since some of them turn out to be very useful? I tried "git help v". That was wrong. It would have been better to try "git help help", but this did tell me about the -all flag, which actually lists out all of the commands, and there are quite a few of them. So, good hunting. 130 +# Switch to the master branch 131 +git checkout master 152 152 153 -= Git Everyday Tasks = 133 +# Merge your working branch with the master 134 +git merge workingbranch 154 154 155 - ===Howto revert?===136 +# Use svn status, svn add and svn commit to commit your changes to the remote svn repository 156 156 157 - Revertingis easy. The followingcommandremovesall modificationstofiles inyour workingopyandbrings themback tothe HEAD.138 +# Switch back to your workingbranch and get back to work. 158 158 159 -{{code}} 160 160 161 -git reset --hard 162 - 163 163 {{/code}}