Ok, after seeing this post by PJ Hyett, I have decided to skip to the end and go with Git.
So what I need is a beginner's practical guide to Git. "Beginner" being defined as someone who knows how to handle their compiler, understands to some level what a Makefile is, and has touched source control without understanding it very well.
"Practical" being defined as this person doesn't want to get into great detail regarding what Git is doing in the background, and doesn't even care (or know) that it's distributed. Your answers might hint at the possibilities, but try to aim for the beginner that wants to keep a 'main' repository on a 'server' which is backed up and secure, and treat their local repository as merely a 'client' resource.
So:
Installation/Setup
- How to install Git
- How do you set up Git? Try to cover Linux, Windows, Mac, think 'client/server' mindset.
- How do you create a new project/repository?
- How do you configure it to ignore files (.obj, .user, etc) that are not really part of the codebase?
Working with the code
- How do you get the latest code?
- How do you check out code?
- How do you commit changes?
- How do you see what's uncommitted, or the status of your current codebase?
- How do you destroy unwanted commits?
- How do you compare two revisions of a file, or your current file and a previous revision?
- How do you see the history of revisions to a file?
- How do you handle binary files (visio docs, for instance, or compiler environments)?
- How do you merge files changed at the "same time"?
- How do you undo (revert or reset) a commit?
Tagging, branching, releases, baselines
- How do you 'mark' 'tag' or 'release' a particular set of revisions for a particular set of files so you can always pull that one later?
- How do you pull a particular 'release'?
- How do you branch?
- How do you merge branches?
- How do you resolve conflicts and complete the merge?
- How do you merge parts of one branch into another branch?
- What is rebasing?
- How do I track remote branches?
- How can I create a branch on a remote repository?
- How do I delete a branch on a remote repository?
- Git workflow examples
Other
- Describe and link to a good GUI, IDE plugin, etc. that makes Git a non-command line resource, but please list its limitations as well as its good.
- msysgit - Cross platform, included with Git
- gitk - Cross platform history viewer, included with Git
- gitnub - Mac OS X
- gitx - Mac OS X history viewer
- smartgit - Cross platform, commercial, beta
- tig - console GUI for Linux
- qgit - GUI for Windows, Linux
- Git Extensions - package for Windows, includes friendly GUI
- Any other common tasks a beginner should know?
- How do I work effectively with a subversion repository set as my source control source?
Other Git beginner's references
- Git guide
- Git book
- Git magic
- gitcasts
- GitHub guides
- Git tutorial
- Progit - book by Scott Chacon
- Git - SVN Crash Course
- Git from the bottom up
- Git ready
- gitref.org
- Git visual cheatsheet
Delving into Git
I will go through the entries from time to time and 'tidy' them up so they have a consistent look/feel and it's easy to scan the list - feel free to follow a simple "header - brief explanation - list of instructions - gotchas and extra info" template. I'll also link to the entries from the bullet list above so it's easy to find them later.
GUIs for git
Git GUI
Included with git — Run
git gui
from the command line, and the Windows msysgit installer adds it to the Start menu.Git GUI can do a majority of what you'd need to do with git. Including stage changes, configure git and repositories, push changes, create/checkout/delete branches, merge, and many other things.
One of my favourite features is the "stage line" and "stage hunk" shortcuts in the right-click menu, which lets you commit specific parts of a file. You can achieve the same via
git add -i
, but I find it easier to use.It isn't the prettiest application, but it works on almost all platforms (being based upon Tcl/Tk)
Screenshots | a screencast
GitK
Also included with git. It is a git history viewer, and lets you visualise a repository's history (including branches, when they are created, and merged). You can view and search commits.
Goes together nicely with git-gui.
Gitnub
Mac OS X application. Mainly an equivalent of
git log
, but has some integration with github (like the "Network view").Looks pretty, and fits with Mac OS X. You can search repositories. The biggest critisism of Gitnub is that it shows history in a linear fashion (a single branch at a time) - it doesn't visualise branching and merging, which can be important with git, although this is a planned improvement.
Download links, change log and screenshots | git repository
GitX
Intends to be a "gitk clone for OS X".
It can visualise non-linear branching history, perform commits, view and search commits, and it has some other nice features like being able to "Quicklook" any file in any revision (press space in the file-list view), export any file (via drag and drop).
It is far better integrated into OS X than
git-gui
/gitk
, and is fast and stable even with exceptionally large repositories.The original git repository pieter has not updated recently (over a year at time of writing). A more actively maintained branch is available at brotherbard/gitx - it adds "sidebar, fetch, pull, push, add remote, merge, cherry-pick, rebase, clone, clone to"
Download | Screenshots | git repository | brotherbard fork | laullon fork
SmartGit
From the homepage:
You can download it from their website.
Download
TortoiseGit
TortoiseSVN Git version for Windows users.
Download
QGit
Download
gitg
Features
Download: releases or source
Gitbox
Download
Gity
The Gity website doesn't have much information, but from the screenshots on there it appears to be a feature rich open source OS X git gui.
Download or source
Meld
Downloads
Katana
A Git GUIfor OSX by Steve Dekorte.
Free for 1 repository, $25 for more.
Download
Sprout (formerly GitMac)
Focuses on making Git easy to use. Features a native Cocoa (mac-like) UI, fast repository browsing, cloning, push/pull, branching/merging, visual diff, remote branches, easy access to the Terminal, and more.
By making the most commonly used Git actions intuitive and easy to perform, Sprout (formerly GitMac) makes Git user-friendly. Compatible with most Git workflows, Sprout is great for designers and developers, team collaboration and advanced and novice users alike.
Download | Website
Tower
A feature-rich Git GUI for Mac OSX. 30-day free trial, $59USD for a single-user license.
Download | Website
EGit
Download | Website
Git Extensions
Open Source for Windows - installs everything you need to work with Git in a single package, easy to use.
Download
Big thanks to dbr for elaborating on the git gui stuff.
SourceTree
SourceTree is a free Mac client for Git, Mercurial and SVN. Built by Atlassian, the folks behind BitBucket, it seems to work equally well with any VC system, which allows you to master a single tool for use with all of your projects, however they're version-controlled. Feature-packed, and FREE.
Download | Website
How do you merge branches?
If you want to merge a branch (e.g.
master
torelease
), make sure your current branch is the target branch you'd like to merge into (usegit branch
orgit status
to see your current branch).Then use
(where
master
is the name of the branch you want to merge with the current branch).If there are any conflicts, you can use
to see pending conflicts you have to resolve.
How to track remote branches
Assuming there is a remote repository that you cloned your local repository from and also assuming that there is a branch named 'some_branch' on that remote repository, here is how to track it locally:
Gity: http://macendeavor.com/gity
How do you 'tag' a particular set of revisions
How do you 'mark' 'tag' or 'release' a particular set of revisions for a particular set of files so you can always pull that one later?
Using the
git tag
command.To simply "tag" the current revision, you would just run..
To list the current tags, simply run
git tag
with no arguments, or-l
(lower case L):To delete a tag, you use the
-d
flag:To tag a specific (previous) commit, you simply do..
For example:
Note: by default, git creates a "lightweight" tag (basically a reference to a specific revision). The "right" way is to use the
-a
flag. This will launch your editor asking for a tag message (identical to asking for a commit message, you can also use the-m
flag to supply the tag message on the command line). Using an annotated tag creates an object with its own ID, date, tagger (author), and optionally a GPG signature (using the-s
tag). For further information on this, see this postAnd to list the tags with annotations, use the
-n1
flag to show 1 line of each tag message (-n245
to show the first 245 lines of each annotation, and so on):For more information, see the git-tag(1) Manual Page
How can I create a branch on a remote repository?
Assuming that you have cloned your remote repository from some single remote repository.