How to fix "Your branch is ahead of 'origin/master' by 1 commit."?
You can reset your local branch to the one in orig, then push to your fork
git checkout master
git reset --hard origin/master
git push --force origin master
Your local repo and fork master branch will be the same as the original repo.
If need clean: git clean -f -d
I have had the same issue a couple of times now and the below is the solution I wrote down for myself. I don't know all the details but I know it got me out of trouble :).
Rolling back on Commits. (run "git status" between each step)
- e.g. "Your branch is ahead of 'origin/dev' by 2 commits."
- git reset HEAD^:
- This removes one committed file at a time (I think)
- There will be a bunch of (red) staged/untracked files. Don't panic.
- "Your branch and 'origin/dev' have diverged, and have 1 and 5 different commits each, respectively."
- Repeat step 1. until git status "Your branch is behind 'origin/dev' by 5 commits"
- Now we want to remove all those changes so we can later pull origin back in.
- git restore *
- Removes all the staged changes
- Now there may just be some Untracked files. Manually go delete them in the folder.
- git pull origin dev.
- This should be the latest dev pulled from origin.
Use the command below :
git reset --hard HEAD