I’ve come back to a project that I haven’t visited for a while. I did git pull and git config pull.rebase false (maybe I shouldn’t have), but got something like this after git status:
On branch develop
Your branch is ahead of 'origin/develop' by 27 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
I only want to have tha same code as develop and nothing else. What can I do to remove all commits locally and just have the same code as remote develop?
>Solution :
To reset your branch to the remote’s state and remove all your commits that are not pushed yet (I believe that’s what you want to do) :
git reset --hard origin/<branch>
So in this case it would be :
git reset --hard origin/develop
Be careful with this as you would lose all of those commits !
If you want to keep a copy just in case, you could clone your repository in another folder and start working from there, keeping your unpushed commits just in case.
git clone <your repo>/develop