0

I have forked my repo from some other repo and commited some changes.Now I want to update my repo with respect to the original repo and delete the commits I have made.I am first trying to revert it to the point where I have forked the repo then I will update it using:

git remote add upstream url
git fetch upstream

for reverting back I use

git reset --hard commithash
git push -f origin master

but it always display :

everything is up-to-date.

I am new to git and github and don't know what to do.

3
  • 1
    If it says that everything is up-to-date that means there is no difference in the remote and local branches. May be the commits you are resetting were never pushed to remote, they were only on your local. So, your remote was always at the <commithash> that you mentioned. Apr 16, 2015 at 8:27
  • in the github it displays your repo is behind the master repo by x commits but when i fetch and push from upstream it displays everything is uptodate Apr 16, 2015 at 8:30
  • What do you mean by, "when i fetch and push from upstream"? After fetching, you need to merge, which is the equivalent of git pull. If you want to pull changes from master to yours, the function would be pull, not push. Apr 16, 2015 at 9:03

2 Answers 2

0

You should save your commit changes with "stash". Once you have updated your repo, you will be able to "unstash", it means you will re-apply your commits.

You can check this link that was very helpfull to me. Example with Android Studio

Hope this helps !

0

You can:

  • Checkout the commit previous to your first modifications;
  • Make a branch (something like update-version-2.0.0);
  • Update the branch;

After that, you can simply use the new branch if you don't want your modification or merge the branches in the future, making it easy to resolve conflicts if there is any or revert back any of the changes if desired.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.