====== Git Notes ====== * [[http://gitref.org/|Git Reference]] * [[http://gitimmersion.com/|Git Immersion]] - Guided tour through Git * [[http://think-like-a-git.net/|Think Like (a) Git]] - A Guide for the Perplexed * [[http://en.wikipedia.org/wiki/File:Git_data_flow_simplified.svg#|Git data flow diagram]] * [[http://osteele.com/archives/2008/05/my-git-workflow|A Git Workflow]] * [[http://git-scm.com/book|Pro Git]] (Free HTML Book) ===== Git ===== * [[https://code.google.com/p/msysgit/|msysgit - Git for Windows]] ===== Training ===== * [[http://teach.github.com/|Teaching Materials for Git and GitHub]] * [[https://gist.github.com/3761691|2012-09-21 Git and GitHub Foundations Online Notes]] * [[http://teach.github.com/classnotes/2013-02-26-git-github-foundations-online.html|2013-02-26 Git and GitHub Foundations Online Notes]] * [[https://speakerdeck.com/u/matthewmccullough|Presentations by Matthew McCullough]] ===== GitHub ===== * [[https://github.com/defunkt/hub|defunkt/hub]] - Command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier. * [[http://www.emoji-cheat-sheet.com/|Emoji cheat sheet for Campfire and GitHub]] (Emoticons) * [[http://scottchacon.com/2011/08/31/github-flow.html|GitHub Flow]] (vs. git-flow) ===== Tools ===== * [[http://eclipse.github.com/|Git in Eclipse]] * [[http://www.vogella.com/articles/EGit/article.html|Git with Eclipse (EGit) - Tutorial]] * [[https://github.com/github/gitpad|github/GitPad]] - EXE to make Notepad the Git editor (commits, interactive rebase, etc). * [[http://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows|Setting up a Windows editor for commit messages]] * [[http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-a-visual-diff-program|Setting up an external diff tool]] ===== Git & SVN ===== * [[https://speakerdeck.com/u/matthewmccullough/p/migrating-from-subversion-to-git-and-github|Migrating from Subversion to Git and GitHub]] (Slides) ===== VIM Editor ===== * [[http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/|Learn Vim Progressively]] * [[http://www.tuxfiles.org/linuxhelp/vimcheat.html|The Vim commands cheat sheet]] ===== Various Git Commands ===== git diff < diff of what is changed but not staged git diff --staged < diff of what is staged but not committed git diff HEAD < diff of the current state of the files as compared against the most recent commit git show < diff of a specific commit git log origin/master..master < lists unpushed commits git log origin/master..master --oneline git commit --amend < change last commit message git rebase -i < choose and mark the commit to "reword" git reset --hard HEAD < Restore working to last committed state git reset --hard < same git reset --hard MYTAG < Restore working to MYTAG tag reference point git log --stat -M < shows "renames" instead of deletes and adds git log --stat -C -C < shows "copies" if that's likely what happened git log --stat --find-copies-harder < same git log -- deletedFile.txt < find a deleted file in log history git add -u . < Add tracked files in the staging area rather than the working tree git add -A . < Add files in the working tree in addition to the staging area git add --all . < same git fetch < retrieval without merging to work in progress git merge < merges what has been fetched in to working files git pull < retrieval with merge into work in progress git log --graph --pretty=oneline --abbrev-commit --decorate --all -5 git branch < local branches git branch -r < local remote branches git branch -a < local and local remote branches git ls-remote origin < remote branches git ls-remote < same git branch < create new local branch git checkout < switch to local branch git checkout -b < create and switch to new local branch git push -u origin < publishes local branch to remote origin git checkout master git merge < merges local branch to checked out branch (master in this case) git stash < push onto a local stash stack git stash pop < pop the local stash stack git stash apply < same git stash branch < create branch from top of local stash stack git branch THETAGNAME < create branch from tag THETAGNAME git config --get-regexp alias < list aliases Alias examples: git config --global alias.aliases "config --get-regexp 'alias.*'" git config --global alias.s "status -u -s" git config --global alias.logfive "log --graph --pretty=oneline --abbrev-commit --decorate --all -5" [alias] hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short aliases = config --get-regexp \"alias.*\" unpushed-commits = log origin/master..master --date=\"local\" --pretty=format:\"%H %cd - %s\" statii = "!f() { echo \"Unpushed Commits:\"; echo; git unpushed-commits; echo; echo \"Status of Tracked Files:\"; echo; git status -uno; }; f" unpushed = "!f() { git log origin/$1..$1 --date=\"local\" --pretty=format:\"%H %cd - %s\"; }; f" pullr = "!f() { echo \"Stashing uncommitted work...\"; echo; git stash clear; git stash; echo; echo \"Pulling latest changes with rebase...\"; echo; git pull --rebase; echo; echo \"Applying previously stashed work...\"; echo; git stash apply; }; f"