Pull rebase causing file changes and many other commits

Kindly advise on how to deal with a rebase that brings about very many old commits and presents them as new commits @jwnasambu, @reagan , @sharif, @dkayiwa

Actually i saw this and i was thinking may be @teleivo had made some changes which wasn’t the case . Personally i would close this ticket and open a new on if otherwise cc @dkayiwa @teleivo @ibacher

1 Like

So, generally speaking, instead of doing a rebase to get a PR up-to-date, I would advise doing a merge. The merge commit can always be squashed when the PR is committed, so something like git merge upstream/master rather than git rebase upstream/master. That should make the history easier for GitHub to understand. A rebase will generally be fine if all the PR-related commits occur after the changes to upstream, but that appears to not be the case here.

That said, as @sharif indicated, in this case, it may just be easier to close the PR and create a new one.


I deleted the repository, cloned it afresh, set the upstream, and this is what git pull --rebase upstream master gives me @sharif, @herbert24, @ibacher, @dkayiwa, Kindly advise on the way forward.

1 Like

Can you do a git reset --hard origin/master though this might cause you to lose your current local changes.

1 Like

I get this feed back. HEAD is now at 373c34bd2 Upgrading hibernate-validator to 5.4.0-Final - TRUNK-5498

Is it possible to share the screenshot of a detached HEAD

How did you get your branch into such a state?

I always rebase with

git fetch origin            # Updates origin/master
git rebase origin/master    # Rebases current branch onto origin/master

But if you’re having issues like this, @ibacher’s suggestion may be more reliable. Just make sure to squash the merge commits, as he suggests.

1 Like

It still shows commits which i have not made. After running the git pull --rebase upstream master , the commits showed up. I had to delete the repo on my pc and cloned again. But the challenge has persisted.

The challenge persisted even when you cloned a fresh openmrs-core?? can you share the screen , am sure should have worked

@gracebish feel free to delete the repository and fork a fresh there you will be sure of a clean branch. But if you can revert the changes and update the branch well and good, but you are bound to have log failures when committing the changes.

1 Like

Another trick you can do would be to start a new branch off master and then cherry-pick your commits from your old branch.

git checkout master
git pull
git checkout -b my-new-branch
git log my-old-branch
# copy commit hashes
git cherry-pick [commit hashes]

I have never deleted and re-cloned a repo; there’s no reason you should ever have to do that, unless you’re messing with the files in .git or something.

Whatever command you used that got your branch into that crazy state—try not to do that again.