On Github keelerm84 / GitTalk_May_2013
$ git init our_repo $ ls -a our_repo . .. .git $ ls -a our_repo/.git . HEAD config hooks objects .. branches description info refs
$ git init --bare $ ls -a our_bare_repo . HEAD config hooks objects .. branches description info refs
$ git clone ssh://user@host/path/to/our_bare_repo local_repo_name Cloning into 'local_repo_name'... remote: Counting objects: 4287, done. remote: Compressing objects: 100% (2385/2385), done. remote: Total 4287 (delta 1791), reused 4258 (delta 1762) Receiving objects: 100% (4287/4287), 6.28 MiB | 875 KiB/s, done. Resolving deltas: 100% (1791/1791), done.
$ git remote -v origin https://github.com/git/git.git (fetch) origin https://github.com/git/git.git (push)
$ git remote add keelerm https://github.com/keelerm84/git.git
$ git remote rename origin parent
$ git remote rm parent
$ git branch -a * master
$ git fetch origin From https://github.com/git/git * [new branch] maint -> origin/maint * [new branch] master -> origin/master * [new branch] next -> origin/next * [new branch] pu -> origin/pu * [new branch] todo -> origin/todo
$ git branch -a * master remotes/origin/maint remotes/origin/master remotes/origin/next remotes/origin/pu remotes/origin/todo
$ git checkout -b next origin/next Branch next set up to track remote branch next from origin. Switched to a new branch 'next'
$ git pull origin next
$ git pull
$ git checkout -b --track local_branch remote/branch
--no-track
$ git config --global branch.autosetupmerge [true|false|always]
$ git push origin local_next:next
$ git push origin next
$ git push -u origin next
$ git push origin :next
$ git tag v1.8.3-rc3 v1.8.3-rc2 v1.8.3-rc1
$ git tag -l 'regex'
$ git tag temp_tag HEAD
$ git tag -a -m 'Tagging v.1.8.4' v1.8.4 HEAD
$ git push --tags
$ git fetch --tags
$ git merge experiment
$ git rebase master
$ git rebase --onto master server client
We can finish this up by mering client into master to fast-forward master to C9'
$ git stash
$ git stash save 'Some pithy message'
$ git stash list stash@{0}: WIP on next: ea353ce Sync with 1.8.3
$ git stash apply stash@{0}
$ git stash drop stash@{0}
$ git stash pop stash@{0}
$ git stash apply --indexwill store the working directory and index as it was during the stash
$ git stash branch branch_name
$ git rebase -i HEAD~4
pick e00dd1e describe: Add --first-parent option pick 66fa1b2 Documentation/merge-options.txt: restore `-e` option pick 7370445 completion: regression fix for zsh pick 92c4369 remote-hg: trivial configuration note cleanup pick 5e49f30 remote-hg: fix order of configuration comments pick edca415 Git 1.8.3 # Rebase aed12a7..ea353ce onto aed12a7 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted.
$ git cherry-pick SHA1
$ git blame /path/to/file
$ git blame -L1,30 /path/to/file
$ git blame -L9,13 /path/to/file 35297089 (Jonathan Nieder 2013-03-09 14:00:11 -0800 9) #define NOLOGIN_COMMAND COMMAND_DIR "/no-interactive-login" 2dbc887e (Greg Brockman 2010-07-28 17:31:01 -0700 10) 35eb2d36 (Linus Torvalds 2005-10-23 14:30:45 -0700 11) static int do_generic_cmd(const char *me, char *arg) 35eb2d36 (Linus Torvalds 2005-10-23 14:30:45 -0700 12) { 35eb2d36 (Linus Torvalds 2005-10-23 14:30:45 -0700 13) const char *my_argv[4];
$ git bisect start $ git bisect bad HEAD $ git bisect good SHA1 # Known working SHA1 # As git stops at each commit, check it for the error and mark it as good or bad $ git bisect [good|bad] # If there is a commit you cannot determine, use $ git bisect skip # Once you have found the commit, you can exit the bisect with $ git bisect reset
$ git filter branch --tree-filter 'rm -f password' HEAD
$ git filter-branch --commit-filter ' if [ "$GIT_AUTHOR_EMAIL" = "keelerm@localhost" ]; then GIT_AUTHOR_NAME="Matthew M. Keeler"; GIT_AUTHOR_EMAIL="keelerm@tortugas-llc.com"; git commit-tree "$@"; else git commit-tree "$@"; fi' HEAD
$ git push --force origin master
alias yolo="git commit -am 'Deal with it' && git push --force"