- Got Git? No? Get Git
- Learn About Git
- Get Started with Project Wonder
- Use Git with a Subversion Project
- Git Goodies for WebObjects Developers
- Unique Git Concepts
- Git Annoyances
Got Git? No? Get Git
- Official Download Site: http://git-scm.com/download
- Direct Download Links:
- MacOS X .dmg Binary Installers
- Microsoft Windows .exe Binary Installers
Learn About Git
- Learn the concepts.
- This is an excellent tutorial on the basic concepts behind Git
- Learn the basics.
- Get familiar with the reference materials available online
- Official Git Documentation Site
- Official Git User Manual
- Git Reference
- Git Cheat Sheets
- Linus Torvalds talks about git
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.
Get Started with Project Wonder
The best way to learn a new concept is to actually use it, and what better way than to do something practical like clone (checkout) the Project Wonder source code
- Downloading Wonder Wiki Page
Use Git with a Subversion Project
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
I recommend you just use the git+svn protocol.
Git Goodies for WebObjects Developers
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
EGit
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).
- EGit/Git For Eclipse Users
- User Guide
- Installation
- In Eclipse, select Help > Install New Sofware...
- Select the "Helios" download site from the Work with: combo box
- Expand the "Collaboration" group
- Select the EGit plugin, click Next
- Complete the install process and agree to the license, etc.
- Restart Eclipse.
Git Bash Completion
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:
Git Bash Auto-Completion
GitX git GUI
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.
GitX Home Page
Open in GitX
Git Tower
Git Tower is a commerical app for those of you who just get panic attacks at the thought of using the Terminal.
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.
Miguel Arroz
Unique Git Concepts
Rebasing
Rebasing is unique to git. There is no counterpart in Subversion.
Rebasing cuts down on the spaghetti history of merging and helps to keep history nice and linear.
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.
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.
- If you don't understand rebasing, don't use it You can learn more about it here:
- Use rebase only on private branches
- Use rebase only for commits that have not been pushed to a remote repo
Push/Pull vs Commit/Update
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.
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.
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.
Versions? or Diffs?
One satori that I had while speaking to my git guru (thanks, Kieran) is this. Subversion is all about versions. CVS was all about versions. We have been working with these a long time and the ideas are sticky. Git is not about versions. It is about diffs. Diffs are the main thing. If you think about it, this makes sense. You have thoughts and make changes and those diffs are the product of your work. If you get those diffs into something, that is good, but the work product was the diffs.
All this rebasing and such may seem odd. But the main thing is the diffs. I have edits from a two-week old repository. What do I do? I move the diffs so that they are diffs from the latest code. That is a rebase. When we make edits, we are used to being over-concerned about merge conflicts. But they do not happen all that often and are actually easy to deal with when they do, if the tools are oriented to making them easy to deal with. If we are worrying about the versions and not the diffs, we are paying attention to the paper we write on and not to the words we are putting down.
Internally, git keeps track of text fragments and not files. Why is this? Because the versions are not the point. The diffs are. I can imagine how Linus Torvalds had this idea. He was looking at all the versions of all the files in Linux and all the e-mails of all the diffs. These are two separate worlds. It is conceptually painful to look at every diff, find its source and see how it maps to what now exists. At some point, he must have realized that all he needed was the e-mails. If he had no files any longer, but all the e-mails, he could always reconstruct the files. He would not have to make the conceptual switch from the diffs to the versions and back. Collectively, those e-mails with the diffs defined everything that needed to be said. Quod erat demonstrandum.
How Easy Are Branches?
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.
Might you end up with too many branches? Perhaps. How messy is your desk? 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.
Keep in mind that the difficult part of what you do should be the thinking. Git makes it easy to organize and share your thoughts as branches. Your local copies may be messy or not. They are the thoughts you have in your head and lots of those thoughts will stay there and never see the light of day and that is ok. But when you have clarified your thoughts, git will make it easy to share them.
Git Annoyances
How to revert?
Reverting seems really complicated. Perhaps the simplicity of "svn revert" has fooled me. For example, say that a bunch of files get changed under you (such as, when eclipse helpfully changes the encoding specified for all the .woo files in a project without saying a word about it), how can you revert them. You might think "git revert" would work, but (if I understand it) that is only for reverting a checkin. Delete the file and do a revert? Nope. I know, svn will do just fine there, but not git. In order to do this, you need:
git ls-files
d | xargs git checkoutIsn't that intuitive?