GIT CheatSheets
Remove all commits
$ git checkout --orphan wip # Create a new branch
$ git add -A # Add all files in this new branch
$ git commit -m 'First commit' # Commit all changes
$ git branch -D master # Remove the branch
$ git branch -m master # Rename the branch in the new name master
$ git push -f origin master # Update to the remote repository
Migrate project
$ git remote rm origin
$ git remote add origin https://<url repo git>
$ git push origin --all
Remove local/remote branche
git push --delete <branchname> # Delete remote
git branch -d <branchname> # Delete local
Git stash
Pop into stash repository
If you need to save your current work before you do the pull, you can use git stash:
$ git stash list # List all stashes
$ git stash push -u -m "Before merge from remote"
$ git pull
$ git stash pop # Pop into the local repository
Preview before merging
Preview from remote
$ git fetch # Fetch changes from remote but no merge
$ git diff HEAD..origin/main # Show the difference
$ $ git merge # Merge from the remote