Skip to content

Latest commit

 

History

History
59 lines (49 loc) · 1.56 KB

Git.wiki

File metadata and controls

59 lines (49 loc) · 1.56 KB

Table of Contents

Git

Changes commited to master, not pushed yet

git reset --soft HEAD~1

Commits, showing from other PRs

git fetch origin git rebase origin/master git push --force --set-upstream origin $(git branch --show-current)

Graph of commit log history

git log --graph --decorate --pretty=oneline --abbrev-commit

Rebase

git checkout master && git pull git checkout - git rebase master git push origin $(git branch --show-current) --force

Remove files from a commit

git reset --soft HEAD^ git reset HEAD path/to/unwanted_file git commit -c ORIG_HEAD

Revert to origin's master branch's version of file

Assuming you did not commit the file, or add it to the index, then:

git checkout -- filename

Assuming you added it to the index, but did not commit it, then:

git reset HEAD filename git checkout -- filename

Assuming you did commit it, then:

git checkout origin/master filename

Assuming you want to blow away all commits from your branch (VERY DESTRUCTIVE):

git reset --hard origin/master

Squash all commits in Branch

git checkout yourBranch git reset $(git merge-base master yourBranch) git add -A git commit -m "one commit on yourBranch"

Squash all commits to rebase easily

git checkout master git pull git checkout - git reset --soft origin/HEAD git commit -m "squashing commits" git rebase master git push -f

git log git rebase -i HEAD~[NUMBER] git push origin branchName --force git checkout master git pull origin master git checkout branchName git rebase master git push origin branchName --force