fantastic-git
Contents
๐
Reading - Atlassian Git Tutorial
- git-cheat-sheet
- Learn Enough Git to Be Dangerous
- Git Workflows for Pros: A Good Git Guide
- Git from the inside out
- git-game
- Introduction to Git - talk by Scott Chacon
- Git Tutorial โ Git Fu With The Command Line
- Git Immersion
Repos
- gitflow Git extensions to provide high-level repository operations for Vincent Driessen's branching model
- diff-so-fancy Good-lookin' diffs with diff-highlight and more
GitHub
- gitify GitHub Notifications on your menu bar.
- twitter-for-github Twitter handles for GitHub
- octotree Code tree for GitHub and GitLab
- isometric-contributions Render an isometric pixel art version of your contribution graph in Chrome and Safari.
- github-s3 Shell scripts that make it really easy to archive and restore repositories between GitHub and AWS S3
- mention-bot Automatically mention potential reviewers on pull requests.
Commands
๐ข
Tag List all tags
git tag
Tag a commit
git tag -a v1.4 -m "my version 1.4"
Delete remote tags
git push --delete origin tagname
git push origin :tagname
Push tag to remote
git push origin tagname
Rename tag
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags
Move tag from one commit to another commit
git push origin :refs/tags/<tagname>
git tag -fa tagname
git push origin master --tags
โ๏ธ
Remote List all remote
git remote
Rename remote
git remote rename old new
๐
Branch List all branches
git branch
Create a branch
Create the branch on your local machine and switch in this branch
git checkout -b branch_name
Create branch from commit
git branch branch_name sha1_of_commit
Push the branch to remote
git push origin branch_name
Rename local branch
Rename other branch
git branch -m old new
Rename current branch
git branch -m new
Rename remote branch
git branch -m old new # Rename branch locally
git push origin :old # Delete the old branch
git push --set-upstream origin new # Push the new branch, set local branch to track the new remote
Delete a branch
git branch -D the_local_branch
git push origin :the_remote_branch
โ๏ธ
Commit Undo last commit
git reset --hard HEAD~1
Squash last n commits into one commit
git rebase -i HEAD~5
git reset --soft HEAD~5
git add .
git commit -m "Update"
git push -f origin master
Move last commits into new branch
git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch
Pick
git cherry-pick hash_commit_A hash_commit_B
Reflog
Show reflog
git reflog
Get commit
git reset --hard 0254ea7
git cherry-pick 12944d8
Revert
git revert --no-commit 0766c053..HEAD
git commit
Amend
git commit --amend
git commit --amend --no-edit
git commit --amend -m "New commit message"
git commit --amend -m "New commit message"
git push --force <repository> <branch>
๐
Checkout Checkout a tag
git checkout tagname
git checkout -b newbranchname tagname
Checkout a branch
git checkout destination_branch
Use -m if there is merge conflict
git checkout -m master // from feature branch to master
Checkout a commit
git checkout commit_hash
git checkout -b newbranchname HEAD~4
git checkout -b newbranchname commit_hash
git checkout commit_hash file
๐ฆ
Stash
Stash
git stash save "stash name"
git stash
List all stashes
git stash list
Apply a stash
git stash pop
git stash apply
git stash apply stash@{2}
๐
Rebase rebase
git rebase base // rebase the current branch onto base
๐ฏ
.gitignore Untrack
git rm -r --cached .
git add .
git commit -am "Remove ignored files"
๐
Index Remove untracked files
git clean
Remove file from index
git reset file
Reset the index to match the most recent commit
git reset
Reset the index and the working directory to match the most recent commit
git reset --hard
๐ป
Misc Conflicting git rebase
git checkout --ours foo/bar.java
git add foo/bar.java
Resolve git merge conflict
theirs
git pull -X theirs
git checkout --theirs path/to/the/conflicted_file.php
git checkout --theirs .
git add .
git checkout branchA
git merge -X theirs branchB
Merge from master into feature branch after push
git checkout feature1
git merge --no-ff master