1

I have a basic doubt on GIT concepts.

  • I have a branch master and another branch called feature.
  • I am working on feature branch. I deleted 10 existing files which originally was added by some other author and committed the changes to feature branch.
  • I added back 4 of the deleted files and committed these changes as well to my feature branch.
  • I create a pull request for feature branch to master. In the diff in pull request with master, as expected I see 6 files deleted.

My question is, now if the pull request is merged to master, would GIT show history of 4 files which has been re-added as added by me or the original author?

Nitin Mathur
  • 551
  • 5
  • 19
  • Git doesn't have file history. Git commits *are* history. Asking for the history of a file tells Git: *look at the commit history; see which commits touched the file; with `--follow`, guess at any rename operations.* – torek Oct 07 '19 at 05:29

1 Answers1

1

It will show those files with the current history they have from feature branch:

git log --pretty='%an %ad -- %cn %cd' -- aRe-AddedFile

Provided you have re-added the file with the exact same content and name (as in here), Git will follow that file history from feature branch.

Once the PR is merged, GitHub will show the last commit for that file as part of master history: you would be the author.
As part of the merge commit representing that merged PR, the feature branch history would show the origin author.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250