Skip to content

Instantly share code, notes, and snippets.

@defilerc
Last active November 15, 2018 13:08
Show Gist options
  • Save defilerc/cd858ee47efbbef84d3b093043eba212 to your computer and use it in GitHub Desktop.
Save defilerc/cd858ee47efbbef84d3b093043eba212 to your computer and use it in GitHub Desktop.
# undo last commit (not pushed)
git reset HEAD~
# delete remote branch
git push origin --delete feature/login
# stash changes, including untracked files and give a store message (git save has been deprecated in favor of git push)
git stash push --include-untracked --message "publish scripts & command performance tests"
# commit partial file changes
git add -p <filename> # (-p is short for --patch)
# [y,n,q,a,d,K,g,/,e,?] y: yes, n: no, q: quit, a: all (stage entire file), d: (do not stage file at all), K: (skip hunk),
# g: select specific hunk, / (search hung using regex), e: (edit hunk), ? (print help)
# revert changes to local copy only (index not included)
git checkout .
# unstage files
git reset
# when "cannot lock ref 'refs/remotes/origin/current_visa_direct': unable to resolve reference
# 'refs/remotes/origin/current_visa_direct': reference broken
rm .git/refs/remotes/origin/(dir name)
git fetch
# git rebase -i (interactively) -p (squash merge commits). rebase <source> to <target> example:
git checkout <source>
git rebase -i -p <target>
git checkout <target>
git merge <source>
# abort rebase
git rebase --abort
# skip conflict in current commit
git rebase --skip
@konsP
Copy link

konsP commented Jul 13, 2018

👯‍♀️

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