- 19 Git Tips for Everyday use http://www.alexkras.com/19-git-tips-for-everyday-use
- Git Hot Tips by Wes Bos https://wesbos.com/git-hot-tips/
- Git Reference https://help.github.com/categories/github-pages-basics/
- Pro Git Online Book http://git-scm.com/book
- Git Ready http://gitready.com
- Quick Command Practice http://try.github.com
- Git Real http://www.codeschool.com/courses/git-real
- How to GitHub: Fork, Branch, Track, Squash and Pull Request http://gun.io/blog/how-to-github-fork-branch-and-pull-request
- Learn Git Online http://learn.github.com/p/intro.html
- Teach Github https://github.com/github/teach.github.com
- Git: The Simple Guide http://rogerdudler.github.com/git-guide
- Git Immersion http://gitimmersion.com
- Git Branching http://pcottle.github.io/learnGitBranching/
- Git Cheat Sheet https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet
Welcome to my practice git repository where you can eff up as much as you'd like plus work with a real, living, breathing person on the other side. Here we learn all things git. Feel free to send me Pull Requests just to discover what it's like when a Repo Master asks you
"Can you squash your commits for us"
and you're all like...
"How the hell do I do that?"
This is where we make those mistakes ... so don't be scared :)
Fork this repo and send me a Pull Request with anything from Grandma Peggy's Crumbled Oatmeal Cookie Recipe to your favorite Sublime Text 2 preferences. It's all good yo! Learning is the prize in this game.
git clone [email protected]:<user_name>/the-repo-you-are-cloning.gitClones your remote origin repo locally
git fetch upstreamPulls in the remote changes not present in your local repo. Downloads objects and references from another repository.
git merge upstream/masterMerges any changes fetched into your working files
git add <file>Start tracking new files and also stage changes to already tracked files
git status & git diff
- Tells us what files and assets have been modified and staged
git status -sThis will display what files have been removed, changed or modified.
- (M) - modified
- (A) - added
- (AM) - file has not been altered since it was last added
git commit -m 'the message goes here for the commit'Records a snapshot of the project into your history at the time of your commit.
git add '*.<file_extension>'This command adds all file types with the same extension, especially from different directories. Without quotes the command will only execute within the same directory it's been called from.
git rm --cached <file>Unstages a file from the working tree (i.e. stops tracking the file).
git logRemembers all the changes we've committed so far, in the order we committed them.
git log --summarySee where new files were added for the first time or where files were deleted.
git remote add origin [email protected]:<user_name>/<repo_name>.gitCreates a brand new remote repository.
git remote -vShow a list of the current remote repositories
git reset <file>Removes the desired file from staging area.
git branch -rList all the remote branches currently tracked
git remote prune originDeletes branch locally if it has been removed remotely. Helps to remove stale references.
git checkout -- <target>Changes the desired target back to the state of the last commit. A target can be a file or a directory (for example).
git rebaseRebase allows you to easily change a series of commits, reordering, editing, or squashing commits together into a single commit.
Be warned: it's considered bad practice to rebase commits which you have already pushed to a remote repo. Doing so may invoke the wrath of the git gods. https://help.github.com/articles/interactive-rebase
git add <list of files>(i.e. git add readme.md license.txt. Can be multiples)
git add --allAdd all the new files since last
git add *.txtAdd all txt files in directory
git diffShow unstaged differences since last commit
git diff --stagedGets the staged differences and displays what has changed since our last commit
git reset HEAD <file>Head is the last commit on the current branch we are on. What if you stage something you didn't need to be staged? This is the key.
git checkout -- <file>Reset all changes to a file since last commit
git reset --soft HEAD^What if you regret a commit? This will undo your last commit. (^ means move commit before HEAD and puts changes into staging).
git reset --hard HEAD^Traverse through commits and revert back one by one.
git reset --hard HEADUndo Last commit and all changes
git commit --amend -m "added another file to the commit'New commit message will override previous commit message
"Remotes are kinda like bookmarks"
git remote -vShow the current remote repos
git remote add <name> <address>Add a new remote repo
git remote rm <name>Remove remote repo
git fetchPulls down any changes but doesn't merge them
git branch <branch name>Makes a new branch
git checkout <branch name>Switching branch and on a different timeline
git merge <branch>Merges branch into master
git branch -d <branch name>Deletes branch
git checkout -b <branch name>Creates a new branch and then switches to it
:wq + enterVI Editor Quick Key Exit
g fetch origin
git checkout -t <remote>/<branch>Fetches a remote branch not available locally also reference issue #7
git push -u origin master (remote repo name[origin], local branch name[master])Lets you just run git push later on without specifying name and branch
git pullPull changes in and syncs up your repo. Doesn't update local code
git branch -rList all remote branches
git remote show originShow all the remote branches
git push origin :<branch name>Deletes the remote branch
git branch -D <branch name>Delete the local repo branch and if you don't want the commits any longer on it then delete them too.
git remote prune originDeletes the branch locally if it has been removed remotely. Helps to remove stale references.
"Merge commits are bad"
git rebaseMove all changes to master local which are not in origin/master remote to a temporary area
git logViewing the commits history
git config --global color.ui trueColor codes the commit SHA
git log --pretty=onelineor
git log --graph --oneline --allCommit and history is one line
git log --pretty=format:"%hExactly how you want the output using placeholders (use git help log)
git log --until <value>Date Ranges. For example you could grab everything from the year 2013 using git log --until 2013
git rm <filename>Removes file completely
git rm --cached <file names>Won't be deleted from your file system, but keeps the local changes still.
git helpgit help <command>