Last active
April 22, 2019 06:30
-
-
Save zmiftah/2dd4100a1aedb7a9413d7fcd9a2ee329 to your computer and use it in GitHub Desktop.
Git Command History so that I won't forget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q: How to add files | |
A: git add -A | |
Q: How to commit changes | |
A: git commit -am "Comment" | |
Q: How to see history of commits | |
A: git log --oneline --decorate | |
Q: How to undo `git add -A` | |
A: git reset --keep | |
Q: How to create and checkout a branch | |
A: git checkout -b branchName | |
Q: How to rename a branch | |
A: git branch -m branchName newBranchName | |
Q: How to merge a branch | |
A: git checkout master; git merge branchName | |
Q: How to push a branch | |
A: git push origin <branchName> | |
Q: How to remove a commit from remote | |
A: git push origin +HEAD^:master | |
Q: How to add remote repository | |
A: git remote add origin git@<webiste>:<username>/<repository>.git | |
git remote remove origin | |
git remove -v | |
Q: How to remove a commit on remote | |
A: git push <branch> +HEAD^:<branch> | |
Q: How to modify existing, unpushed commits? | |
A: git commit --amend | |
Q: How to undo commit | |
A: git reset HEAD~ | |
Q: How to use stash | |
A: git stash | |
git stash list | |
git stash apply | |
git stash clear | |
Q: How to show diff commits by a file | |
A: gitk filename.ext | |
P: The remote end hung up unexpectedly while git cloning | |
S: git config --global http.postBuffer 524288000 | |
Q: How to delete a file from git repo | |
A: git rm --cached <filename> | |
Q: How to delete a branch remotely | |
A: git push origin --delete <branch_name> | |
Q: How to delete a branch locally | |
A: git branch -d <branch_name> | |
git branch -D <branch_name> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: rebase