Awesome
man-git
a collection of git tips and tricks
Tips and Tricks (by command)
git branch
Delete a local branch
git branch -d <branch-name>
Delete an unmerged local branch
git branch -D <branch-name>
source: git man pages
git checkout
Checkout specific file from another branch
git checkout <branch_name> -- <paths>
git diff
Show the files and changes that have been staged
git diff --cached
Show the difference between two (local) branches
# diff to show what is in branch-2 that is not in branch-1 (..)
git diff branch-1..branch-2
# diff to show what is in branch-1 that is not in branch-2 (..)
git diff branch-2..branch-1
# diff based on the common ancestor of branch-1 and branch-2 (...)
git diff branch-1...branch-2
# list only the names of the files
git diff branch-1..branch-2 --name-only
# list the status and name of each file
git diff branch-1..branch-2 --name-status
git push
Delete a remote branch
git push origin --delete <branch-name>
git remote
Change/Update the remote repository URL
git remote set-url <remote-name> <remote-url>
# for example, change origin url to github.com/user/repo-name
git remote set-url origin https://github.com/user/repo-name.git
git reset
Squash some commits
# move the head back two commits as the contents of those
# two commits gets squashed onto the index
git reset --soft HEAD~2
# commit the now squashed changes
git commit
git tag
Delete a remote git tag
git tag -d v1.0.0
git push origin :refs/tags/v1.0.0
Links (by command)
git fetch
git ls-files
List all files staged for deletion (and then do something with them)
# simply list the files staged for deletion
git ls-files --deleted -z
# perform a `git rm` on the files, putting them on the index
git ls-files --deleted -z | xargs -0 git rm
# perform a `git checkout --` on the files, unstaging them
git ls-files --deleted -z | xargs -0 git checkout --
git pull
git reset
Resources
- A Practical Git Introduction
- Introduction to Git and GitHub
- git source code on GitHub
- Pro Git book
- git-scm reference
- git-scm videos
- Heroku Git Cheat Sheet
- Interactive Git Cheat Sheet
- Official git Wiki
- Try Git interactive tutorial
- Git Magic
- Self-hosted Git Server
- Linus Torvalds on git: Google Tech Talk
- r/git
- git ready
- git for computer scientists
- a git tutorial and primer
- Ry's Git Tutorial
- git immersion
- think like a git
- Visualizing Git Concepts with D3 (GitHub repo)
- git - the simple guide
- Changing history, or How to git pretty
- git cheat sheet
- How to handle big repositories with git
- Ry's Git Tips and Tricks
- 25 Tips for Intermediate Git Users
- A few git tips you didn't know about
- Things you didn't know about Git
- A Hacker's Guide to Git
- Git merge vs. rebase
- Git Fetch and Merge
- Using topic branches and interactive rebasing effectively
- Move a subdirectory from one git repository to a subdirectory of another, without losing commit history
- 25 Tips for Intermediate Git Users
- Git and GitHub Cheat Sheet
- How to Write a New Git Protocol
Commit Messages
Tools
- hub - hub helps you win at git
- git-extras - little git extras
- gitfs - version controlled file system
- elastic-git - Store data in git, find it in Elasticsearch
Workflows
License
© 2015 Josh Branchaud
This repository is licensed under the MIT license (see LICENSE
for
details).