Skip to content

Instantly share code, notes, and snippets.

@enxt
Last active November 19, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enxt/c88619ccc61bbe1c8c78c85882c414ae to your computer and use it in GitHub Desktop.
Save enxt/c88619ccc61bbe1c8c78c85882c414ae to your computer and use it in GitHub Desktop.
Common git commands
  • Create branch with the current changes
    git checkout -b <new_branch> [from_branch]
  • Publish branch
    git checkout <branch-name>
    git push origin <branch-name>
  • Git merge dry-run
    git merge --no-commit --no-ff <branch-name>
    git merge --abort
  • Delete local branch
    git branch -d <local-branch-name>
    git branch -D <local-branch-name> # (optional to force)
  • Delete remote branch
    git push origin --delete <remote-branch-name>
  • Rename branch locally and remote
    git branch -m old_branch new_branch         # Rename branch locally
    git push origin :old_branch                 # Delete the old branch
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment