If I had to summarize git, it would be that it is the version control system that sucks the least. It still has a million different command-line options, most of which are unintuitive to say the least.
- For integrating with Emacs, use Magit.
- The global
.gitconfigis found under
C:/Users/tbarikin Windows. But you can easily edit this using
git config --global --edit.
- If you want to set up your own server through SSH, use Gitolite.
- GitHub. GitHub Help.
- Git, the software, with Windows builds.
- Pro Git is a free reference.
- Show configuration in git with
git config --list.
- Git Reference
- Aha! Moments When Learning Git
- Want to see all the scary options?
git help --all(found through
git help help).
- Amazingly, git lets you rewrite history. You can reorder history so that it makes for sense, squash several commits into one commit, or break one commit into multiple commits.
.gitignorewhen it applies to everyone; otherwise, stuff it in
.git/info/exclude, which is not propagated during clone operations.
git init, to create the repository in the first place.
git commit, to commit your changes. Don't forget that you can use
-mmultiple times for each paragraph.
git clone, to fork a repository.
git add, to add a file. If you added (staged) a file by accident, you can unstage it with
git reset HEAD <file>. (
git statusalso tells you this command.)
git log, which has its own multitude of options, such as
git log --follow filename.
git log --statis also useful.
- Unlike some other version control systems, git can keep track of files even after rename.
git status, shows how Git sees your working tree and index.
git rmto remove a file, and
git mvto move one. Don't use the shell's version of these!
When you're in an
emacsclient editing buffer (for example, when committing), you can use
C-x # (
(server-edit)) to easily close it.
What a pain.
- DOS/UNIX text file conversion can sometimes cause problems:
warning: LF will be replaced by CRLF.. To stop this from happening, set
core.autocrlf = falsewith
git config core.autocrlf false.
A branch is the fundamental means of launching a separate line of development within a software project.
- Branch names allow for hierarchical searching:
bug/pr-17can be obtained with
git show-branch "bug/*".
- Think of branching as "save as", and
git branchwill list all branches.
- To see all branches, you can do
git branch -a. If you want to change where a remote location points to, you can use
git remote set-url.
git branch foowill make a branch called
HEADof your current branch. It does not change your working directory to use the new branch.
- To start working on a different branch, issue the
- Deleting a branch is also easy:
git branch -d bug/pr-3, but you can only delete a branch if the current branch contains those commits. You can use
-Dto override this.
I have a merge conflict! Now what do I do? When doing a
git pull you might get a message such as:
Please, commit your changes or stash them before you can merge. Aborting
You can list your stashes with
git stash list. You can drop the top stash with
git stash drop. See the Git Community Book.
git mergeto merge.
- Being able to do a three-way merge is really, really important. This can be accomplished with the use of
git mergetool, but you'll need an external visual merge tool.
- You can find a list of git supported tools in the folder:
C:\Program Files (x86)\Git\libexec\git-core\mergetools.
- The best free tool for Windows is Perforce Visual Merge and Diff Tools. Git for Windows tip: Use P4Merge as mergetool is a decent guide, but it has some obsolete instructions as they apply to
- A good commercial product is Beyond Compare. See Using Beyond Compare with Version Control Systems. After some experimentation, I've ended up with
bc3: it does quite a bit more than
p4mergein terms of merging files.
- To suppress the 'Hit return to the start the merge resolution tool' prompt:
git config --global mergetool.prompt false.
Beyond Compare is also great for using with
git config --global diff.tool bc3 git config --global difftool.bc3.path \ "C:/Program Files (x86)/beyond compare 3/bcomp.exe"
- As of git 1.7.9, you can do signed commits with
git commit -S.
- Setting user.signingkey will make things easier:
git config --global user.signingkey <gpg-key-id>.
- A Git Horror Story: Repository Integrity With Signed Commits
- Authenticating Git pull requests
git remote add origin URL_TO_GITHUB_REPO.
- Philosophy of altering history (from Version Control with Git): realistic history, with variants fine-grained realistic history and didactic realistic history. Idealistic history.
Gitolite for Ciigar
- Fast Gitolite instructions, specifically for
- To see which repositories are available using your SSH key,
ssh [email protected].
- To get the
gitolite-adminrepository in the first place, perform
git clone [email protected]:gitolite-admin.
- To upgrade gitolite itself, update your clone of the gitolite source and re-run
gitolite setupon the server.
- To add a repository, see here.
There's some fun low-level operations you can try, including
- To make a bare repository:
git init --bare. By convention, bare repositories should end it