Search code examples
gitgithubmergecommitrevision-history

Merges are consuming previous commit history


I'm working on a project with multiple contributors, one of whom is merging from their own forked repo.

Sometimes a merge will appear with the following message:

Merge branch 'branchname' of https://github.com/org/repo into branchname

Whenever this happens a number of commit messages which previously existed get sucked into this commit and no longer appear independently in the history of the branch.

Is this expected behaviour or an error in the way they work?? I want to educate people on how to change their workflow to avoid this so the commit history is more useful, but having never run into it myself am not sure what causes it.


Solution

  • This will happen when you committed to local repository and try to push to remote, there has been a commit pushed by others. at this case, you have to pull the remote commit and merge it to your local commit.

    I think this is not an error, but a expected behavior, It is better to fetch remote commit and merge it to your local worktree before you make a commit.