w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Messed up local git repository - how to "revert a revert" to match last remote commit again?

To get your local to the latest remote, just do git pull. git reset --hard sets your local HEAD to a particular commit and drops all successive changes. So you need to bring the changes down from the remote. You have done a hard reset so you should not have to worry about having local changes that would be merged in to your local.


A revert is a commit that is the inverse of a previous commit. You have not done a revert so you don't need to "revert a revert".


Your problem with getting updates from the remote branch is because after you pushed your local branch to origin, you did not set your local branch to track. In order to push or pull, you need to specify the remote branch to push or pull from/to. To avoid this, you would run git branch -u origin/<branchname> <branchname>. This sets your local branch to track the remote and you will be able to do git pull without a problem. To see the tracking branches, run git branch -vv. This will show the branch name along with the latest commit and the remote branch (if any) that the branch is tracking.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.