What is the `git restore` command and what is the difference between `git restore` and `git reset`?

I have presented git restore (which is still marked as “experimental”) in “How to reset all files from working directory but not from staging area?“, with the recent Git 2.23 (August 2019). It helps separate git checkout into two commands: one for files (git restore), which can cover git reset cases. one for branches (git … Read more

What’s the difference between Git Revert, Checkout and Reset?

These three commands have entirely different purposes. They are not even remotely similar. git revert This command creates a new commit that undoes the changes from a previous commit. This command adds new history to the project (it doesn’t modify existing history). git checkout This command checks-out content from the repository and puts it in … Read more

How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?

Getting back in synch after a pushed rebase is really not that complicated in most cases. git checkout foo git branch old-foo origin/foo # BEFORE fetching!! git fetch git rebase –onto origin/foo old-foo foo git branch -D old-foo Ie. first you set up a bookmark for where the remote branch originally was, then you use … Read more