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.

Magnus Bäck
  • 11,381
  • 3
  • 47
  • 59
user3870509
  • 307
  • 1
  • 3
  • 7
  • 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 that you mentioned. – Raj Srivastava Apr 16 '15 at 08: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 – user3870509 Apr 16 '15 at 08: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. – Raj Srivastava Apr 16 '15 at 09:03

2 Answers2

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 !

Community
  • 1
  • 1
zarvedan
  • 46
  • 4
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.