0

I do git status I got this

Your branch is ahead of 'upstream/develop' by 1 commit. (use "git push" to publish your local commits)

I forgot what changes I made, I think I want sync with upstream branch, how to discard the commit, reset my code as same as my upstream branch?

Sharon Chai
  • 507
  • 1
  • 6
  • 20
  • 1
    Possible duplicate of [how to discard git local branch changes?](https://stackoverflow.com/questions/7846699/how-to-discard-git-local-branch-changes) – Omkar Nath Singh Apr 10 '18 at 03:07

1 Answers1

0

If you want to revert past 1 commit, this will do:

$ git reset HEAD~1  # HEAD~2 if 2 commits and so on

Your last commit should be un-staged if you git status and then if you want to clean them:

$ git reset --hard  # resets changes

For untracked files you can use this:

$ git clean -fd

Then you can pull to upstream as desired. Hope this helps!

vpibano
  • 2,415
  • 1
  • 13
  • 26