Skip to content

Instantly share code, notes, and snippets.

@llama-0
Last active February 11, 2022 10:19
Show Gist options
  • Save llama-0/6f0c00607c944be6cc6ad40985eeb68f to your computer and use it in GitHub Desktop.
Save llama-0/6f0c00607c944be6cc6ad40985eeb68f to your computer and use it in GitHub Desktop.

Delete branch:

git branch -d(-D) branch_name // flag -D means force delete

git push origin -d branch_name

Rebase

git rebase -i HEAD~N, where N is the number of commit you want to squash

pick commit_1 squash commit_2…N-1

or use p for pick, s for squash and etc.

git push -f (или типа того, forse rebase короче)

Amend commit (message)

git commit —amend -m “new commit msg” (если изменить commit message до пуша в ремоут)

git push —force <repository> <branch> (если в ремоут уже запушили, типа git push —force origin feature/featureName)

Rename a branch

Rename the local branch by typing: git branch -m <new_name>

Push the <new_name> local branch and reset the upstream branch: git push origin -u <new_name>

Delete the <old_name> remote branch: git push origin --delete <old_name>

Stash

basics:

git stash

git stash apply

advanced:

git stash push -m "my_stash" // give current stash a name

git stash list // list all recent stashes stored in a stack

git stash pop stash@{n} // apply stash and remove it from the stack, n is the index of the stashed change

git stash apply stash@{n} // apply stash and keep it in the stack

git stash apply my_stash // apply stash by name (TODO: check that it works)

@llama-0
Copy link
Author

llama-0 commented Feb 11, 2022

add stash, update file for .md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment