gitgithubgithub-desktop

GitHub Desktop: Commits lost/deleted


We're currently having a revamp of our website, therefore we created a new branch revamp from main.

Everybody does their changes in the revamp branch.

Now following scenario happened:

It took me a while to figure out, that I can only see the deletion when hitting the button "Compare changes" on https://github.com on the "Merge branch 'revamp' into revamp" commit. (The URL looks somewhat like https://github.com/company-name/project-name/compare/18511cb70baa1b55de4b9b84366a82e8d26eb9a2...9a619b35d10a62d73b2cbf4e0ae9f71e87008822, I think it's git diff, but not too sure.)

I tried:

  1. I cannot "revert changes in commit" on the commit named "Merge branch revamp into revamp", GitHub Desktop says There are no changes to commit (remember, it says No files in commit).
  2. I created a new branch from my last commit "commit 3" until we figured out the solution and I will do his last "commit B" manually, since it was a one-liner.

Is this related to GitHub Desktop? I'm not too familiar with the git commands, so maybe GitHub Desktop used the wrong approach of merging, or simply scrambled up stuff(?)

Any help would be highly appreciated! Cheers, Boris

Edit: Here's how it looks on https://github.com when using the "Compare changes": enter image description here


Solution

  • Everybody does their changes in the revamp branch

    Well, that's the problem. You have multiple people making their own commits on, and pushing, one and the same branch. That is a recipe for trouble, and trouble is exactly what you're getting.

    Instead, everybody should do their "changes" (i.e. make commits) only an their own individually created local branch, and should push that branch to GitHub where the branch can be merged using a pull request. That way:

    (1) The issue "when trying to push his changes, GitHub Desktop notified him, that there were changes that he hadn't pulled yet" will never happen (unless someone rewrites history within their own branch, and in that case pushing with force is fine).

    (2) No one's commits will stomp on anyone else's commits; all the commits will be merged to, and thus interleaved on, the ultimate target branch revamp.