Skip to content

Instantly share code, notes, and snippets.

@kenziebottoms
Last active January 3, 2021 12:41
Show Gist options
  • Save kenziebottoms/7c654bf92967a860d3f4659233704974 to your computer and use it in GitHub Desktop.
Save kenziebottoms/7c654bf92967a860d3f4659233704974 to your computer and use it in GitHub Desktop.
git cheetsheet

Branches

I want all the branches at my disposal

git fetch

Change branches.

git checkout <branch_name>
## or ##
gco <branch_name>

Create new branch and switch to it.

git branch -b <branch_name>
## or ##
gcb <branch_name>

Delete the branch called branch.

git branch -d <branch>
## or ##
gb -d <branch>

Rename the current channel to new_branch_name.

git branch -m <new_branch_name>
## or ##
gb -m <new_branch_name>

Oh Shits

I didn't mean to add file_name!!!

git reset <file_name>

I need to pretend the last five minutes didn't happen. (Assuming you committed intact_commit five minutes ago.)

git reset --hard <intact_commit>
git push origin <branch> -f
## or ##
grh <intact_commit>
ggp <branch> -f

I need to change the commit message on the last unpushed commit.

git commit --amend
## or ##
gca
<commit_message>
<Ctrl+X to save and exit>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment