vektor
vektor

Reputation: 2926

Removing files from repository while merging makes them disappear

Here is a test repo demonstrating the problem: https://bitbucket.org/vektor330/bugtest

The sequence of events is this:

  1. Add some initial commit.
  2. Person A adds Conflict and source to develop.
  3. Person B adds Conflict to master.
  4. Person B merges develop into master, resolving conflict on Conflict using "mine" strategy, and removing source from the repository. This is now an empty commit, but can be commited and pushed back to remote.

The result is: source has disappeared completely from the repository. It appeared in 7dfa23e, there is a log of it appearing in the repo, and it quietly disappeared in 5080a24, without a single trace.

I would expect the commit 5080a24 to show "source removed", what is wrong with Git or my expectation?

Upvotes: 7

Views: 156

Answers (3)

user3188445
user3188445

Reputation: 4774

I'm not sure if your question is about bitbucket, or about git. However, in git, you need to run git show with the -m flag to show a merge commit. Adding that flag reveals the deleted file:

$ git show --summary -m 5080a24
commit 5080a24f6585af2b38161ba55ec4835c7171634d (from 7dfa23e1bfc0a460bfe8071e3623ce9b5959a785)
Merge: a8a08dc 7dfa23e
Author: Matej VitaÌsek <[email protected]>
Date:   Wed Jul 8 09:58:05 2015 +0200

    Hahaaa, a hidden files commit!

 delete mode 100644 files_to_lose/source
$

Upvotes: 1

VonC
VonC

Reputation: 1326774

why this wouldn't show as the "content of the merge commit".

You can visualize the content of the merge commit by selecting the merge commit and each of the two parents in turn.

When you select (in SourceTree) the one from the develop branch (in addition of the merge commit), you clearly see that files_to_lose/source have been removed:

diff

Why does the commit itself not show the missing file?

Because in the case of a merge commit, there are two parents to compare against. SourceTree doesn't offer the diff against those two parents.

GitHub for Mac or Windows does, when you select only the merge commit:

GitHub for Windows

In short, this isn't about Git, just about the Git GUI that you are using.

Upvotes: 7

AlBlue
AlBlue

Reputation: 24060

I think you're confusing "What is stored in Git" and "What BitBucket shows you". There's two separate parents and you can compare against each of those by clicking on the links on the right in BitBucket's interface.

Upvotes: 1

Related Questions