Matti Jokipii
Matti Jokipii

Reputation: 589

Does git change unmodified and uncommited files in merge?

Is it possible that when taking git pull, a file that has not been modified locally and has not been committed locally, changes in automatic merge and that the changes, possibly breaking a file, are then committed and pushed as made by me?

The file changes locally of course if a newer version is on the remote.

But shouldn't that file be identical to the one on the remote after pull, unless i've made local modifications? There aren't any branches involved in these transactions.

I believe i just saw this happend, but don't understand how is it possible. What are the conditions that cause unmodified and uncommitted file to be modified with respect to the remote (origin/master) by merge?

Upvotes: 1

Views: 239

Answers (1)

CodeWizard
CodeWizard

Reputation: 142632

Is it possible that when taking git pull, a file that has not been modified locally and has not been committed locally, changes in automatic merge

Git pull is an alias for 2 commands: git fetch && git merge so there might be a merge when you pull code from server. But you mentioned that you did not modify the code so there shouldn't be any conflict since no local changes needs to be applied to this file.

If the file has been changed during merge of course you can commit, push and break your build, but still the question remained - Who modified the file and changed it.


How to track file changes

git bisect

check when was the file changed

git blame

Check who changed the given line (last updated for the given line)

git log

git log -p <path/to/file/file> will show you all the log entries for the given file.


git diff

Notice that git-diff may show a file changed in a merge commit, even when the file was not changed locally by the local commit being merged. You should look at the diff between the merge commit and the commit on the remote being merged with your local commit to see if the file on remote was actually changed in these transactions.

Upvotes: 3

Related Questions