简体   繁体   中英

Git - edit files in branch while checking diffs

I have two branches in my git repository: master and testing .

I've set up Meld as my difftool so that when I do:

git difftool master..testing

it opens up and shows me file by file the diffs between those branches.

The scenario is: I've made some work on my master branch and I want to see how much it differs with my testing branch. With master checked out, I run the above command and it opens up the difftool (one file at a time).

My question is: what happens if I apply changes that I made in my master branch to files in my testing branch while viewing the diffs? That is: what happens if I edit files in the testing branch with my master branch checked out (as the diffttool apparently allows me to do)?

I have the feeling I'll bork everything doing this.

The short answer, as suggested by Andrew C in the comments, is that nothing will happen.

I rigged up a small repo with both a master and a testing branch. I made changes to the master branch, and then ran git difftool.

Two keys: 1) You ran git difftool with the master branch checked out. This is the red arrow in the picture. Meld is showing you the contents of your file in the master branch. This is the left window of Meld. 2) The testing branch version of the file is in a temporary file. This is the red square in the picture, over the right window of Meld.

Because the testing branch version of the file is in a temporary file, editing and saving the changes in that window will not modify anything in the testing branch, or any branch for that matter.

You won't bork up anything, but you may lose work if you make changes to these temporary files. git difftool is strictly for viewing diffs. Resolving diffs between branches requires git merge/git mergetool.

git difftool的图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM