Undo git pull, how to bring repos to old state

Running git pull performs the following tasks, in order: git fetch git merge The merge step combines branches that have been setup to be merged in your config. You want to undo the merge step, but probably not the fetch (doesn’t make a lot of sense and shouldn’t be necessary). To undo the merge, use git reset –hard to reset the local repository to … Read more

Undo git pull, how to bring repos to old state

Running git pull performs the following tasks, in order: git fetch git merge The merge step combines branches that have been setup to be merged in your config. You want to undo the merge step, but probably not the fetch (doesn’t make a lot of sense and shouldn’t be necessary). To undo the merge, use git reset –hard to reset the local repository to … Read more

Git: How to squash all commits on branch

Another way to squash all your commits is to reset the index to master: This isn’t perfect as it implies you know from which branch “yourBranch” is coming from.Note: finding that origin branch isn’t easy/possible with Git (the visual way is often the easiest, as seen here). Note: git branch –show-current has been introduced with Git 2.22 (Q1 20219). EDIT: you will … Read more

Differences between git pull origin master & git pull origin/master

git pull origin master will pull changes from the origin remote, master branch and merge them to the local checked-out branch. git pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch. The origin/master branch is essentially a “cached copy” of what was last pulled from origin, which is why it’s called a remote branch in git … Read more

Git: How do I force “git pull” to overwrite local files?

⚠ Important: If you have any local changes, they will be lost. With or without –hard option, any local commits that haven’t been pushed will be lost.[*] If you have any files that are not tracked by Git (e.g. uploaded user content), these files will not be affected. First, run a fetch to update all origin/<branch> refs to latest: Backup your … Read more