User Tools

Site Tools


git

Git Cheat Sheet

These are the commands that I look up the most to make sure I'm doing them right. Eventually I'll remember them…

Branches

Create a new branch from current changes

This will create the new branch. When the branch is created, it will be active with the changes from the old branch. Switching back to the old branch will no longer show the changes.

$ git checkout -b <new branch>

Create upstream branch from local branch

Commit any local changes then:

$ git push -u origin <new branch>

Delete a local branch

$ git branch -D <branchName>
Deleted branch <branchName> (was ....).

Delete a remote branch

$ git push origin --delete <branchName>
To git@github.com:<repository>.git
 - [deleted]         <branchName>

If someone already deleted the remote branch, synchronize your local branch list with:

$ git fetch --prune

Merge

Merge branch into current branch

$ git merge <branch>
git.txt · Last modified: 2023/08/18 18:15 by 127.0.0.1