Last active
April 12, 2023 15:48
-
-
Save franckweb/d28f68247b7935ff52174e23b89a508c to your computer and use it in GitHub Desktop.
Git commands
This file contains 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
## zsh git aliases | |
https://github.com/ohmyzsh/ohmyzsh/wiki/Cheatsheet | |
## stash files for later | |
# add files to stash | |
git stash push -m "mystash" | |
# use specific stash | |
# use by number (n) | |
git stash apply stash@{n} | |
# use by name | |
git stash apply stash^{/my_stash_name} | |
# list | |
git stash list | |
# remove stash item | |
# remove latest stash item | |
git drop | |
# remove specific stash item | |
git stash drop stash@{n} | |
# show files of last stash | |
dit stash show -ph | |
## what changed in a file | |
git log --follow -p -- <filename> | |
##Fetch from remote branch to local branch | |
git fetch <remote> <remote_branch>:<local_branch> | |
git checkout <local_branch> | |
## UNDO GIT MERGE | |
# lists undo history for your repo, it references logs | |
git reflog | |
# resets to specific commit (eg. al commit 18) | |
git reset --hard HEAD@{18} | |
## RESET TO LAST PUSH | |
git checkout . | |
## UNSTAGE FILES | |
git reset HEAD -- . | |
## UNSTAGE FOLDER | |
git rm --cached -r myfolder | |
## UNDO COMMIT | |
# undo commit that was not pushed, while keeping the changes in the current branch | |
git reset HEAD~1 --soft | |
## ADD NEW CHANGES TO LAST COMMIT | |
git commit --amend --no-edit | |
## PRINT remotes fetch/push urls | |
git remote -v | |
## delete a pushed commit in remote and local | |
https://ncona.com/2011/07/how-to-delete-a-commit-in-git-local-and-remote/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment