Home > Mobile >  Git - how to proceed with unpushed commits to development branch?
Git - how to proceed with unpushed commits to development branch?

Time:08-06

We have development branch.

From time to time I merge development to my branch with:

git checkout development
git pull
git checkout my_branch
git merge development

Now however, by mistake while I was on development I wrote git merge my-branch.

And the commits from my other branch are now appearing as "5 outgoing" commits on my local development.

We are prohibited to push directly to development. We should use only pull-requests.

Now when I switch to development to make another branch for example - I see unpushed commits.

How should I proceed in this case? My feature branch has been merged with development. But these local commits still remain.

If I delete my local repo and clone again will this help to solve the situation in the least painful way?

CodePudding user response:

My feature branch has been merged with development. But these local commits still remain.

Only locally. You've updated development, but not origin/development, right? And you can't have pushed anyway, if it's prohibited.

If I delete my local repo and clone again will this help to solve the situation in the least painful way?

That will solve your issue in the most painful way. You'll lose your local changes for no reason!

You can simply reset the local branch with

git checkout development
git fetch
git reset --hard origin/development

Before running reset --hard, always double-check you know the current state. If git status shows any local changes, save or stash them first.

In fact, before doing anything in git make sure you know the current state. If you don't want to use a fancy shell prompt, get used to running git status a lot to avoid this and many other trivial mistakes.

  • Related