Git – Distributed Version Control

ToS: Links, Quick-Ref, Reference, Converting hg to git repo

Quick-Ref

git clone url [base]

git diff
git diff -cache

git commit

git branch experimental
git checkout experimental
git checkout master
git merge experimental
git branch -d experimental

git remote add bob /home/bob/myrepo
git fetch bob
git merge bob/master

git gui

Reference

Remove a file from the repository, but not from harddisk (un-track):
git rm --cached

Track a file:
git add

Commit changes to repository, save it, make it persistent:
git commit -m "<comment>"

Merge in upstream changes by

  • Rebasing:
    git pull --rebase
    Fails? Undo the try with:
    git rebase --abort
  • Merging (fetch changes, then merge them):
    git fetch origin/master
    git merge origin/master

Reset vs Rebase vs …

reset <commit-hash> will reset your working tree (current files) to the specified commit.

Rebase: You and origin have a common base, both made changes since that commit. By rebasing you take origins commits and apply them, then apply your changes again.
So you take origins changes and insert them between your common base/commit and your changes.

hg repository to git repository conversionvia

git clone git://repo.or.cz/fast-export.git
mkdir gitrep
cd gitrep
git init
../fast-export/hg-fast-export.sh -r /path/to/hg_repo
git checkout HEAD

I also recommend doing a gc to minimize git repository size. If it is a big repo, consider dropping the –aggressive parameter.

git gc --aggressive