Last active
January 17, 2024 21:39
-
-
Save vatz88/7db6c4c375551b7685c12ead5f91f410 to your computer and use it in GitHub Desktop.
Helpful 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
<!-- delete branch from github and locally --> | |
git push origin --delete <branch-name> | |
git branch -d <branch-name> | |
<!-- add remote to current branch --> | |
git branch --set-upstream-to <remote-name> | |
<!-- Undo last commit --> | |
git reset HEAD~ | |
<!-- squashing commits --> | |
git reset --soft HEAD~3 // squash last three commits | |
git commit -m "New message for the combined commit" | |
git push origin +name-of-branch <!-- + is for force if the commits are already pushed to github --> | |
<!-- see changed files in unpushed commit --> | |
git diff --stat origin/master | |
<!-- Reset local master brach as per remote branch --> | |
git reset --hard origin/master | |
<!-- Restore file from a remote branch --> | |
git restore --source origin/master -- [file path] | |
<!-- git add only the files already in stage --> | |
git diff --name-only --cached | xargs git add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment