The new forums will be named Coin Return (based on the most recent
vote)! You can check on the status and timeline of the transition to the new forums
here.
The Guiding Principles and New Rules
document is now in effect.
I just started using Git for a personal project. Today I made some changes to a file. The changes included some needed fixes, but also introduced new bugs, so I committed the changes on a new branch.
I want to merge the fixes back into the master branch, but keep the other stuff out. Git merge doesn't see conflicts between the files, so it simply merges all of the changes in. If I try to use git diff, it gives me the option to use vimdiff, which I don't know the first thing about. I tried to set up Winmerge as my diff tool in gitconfig as instructed
here, but Winmerge gives me "file not found" errors when it launches.
Right now all I can think of is to download the branched file from github, merge it with the master manually, and commit those changes on master. I feel like I shouldn't need to use that kind of workaround in a
version control system, though...?
I'm running Windows 10.
0
Posts
Alternatively, is this your scenario:
* You have a master repo in github
* You downloaded this locally
* You made some modifications/commits ("Initial Changes")
* You branched locally
* You applied some number of commits ("Fixes")
Did you *only* want to apply your "Fixes" to the master in github, and not your "Initial Changes"?
Now I want to apply the "fixes" to the master, but not the bugs, by going line-by-line in a merge tool and choosing which changes to merge. Gif will theoretically let you compare the same file from two different branches, but I can't get it to launch a merge tool I know how to use.
EDIT: Have you tried not using the settings in the link you provided? Set the mergetool to winmerge and skip the rest. If you're using the latest Git for Windows it seems that winmerge is natively supported. If you run "git mergetool --tool-help" it'll print out a list of tools it supports.
If I enter "git mergetool --tool=winmerge master:filename branch:filename", it tells me no files need merging.
If I enter "git diff master:filename branch:filename", nothing happens.
Nothing also happens if I enter "git difftool --tool=winmerge master:filename branch:filename".
What even is the point of Git if you can't selectively merge changes between branches?
Unfortunately, this is a case of "You're using the tool wrong."
You mentioned that you checked in all your changes in one commit. This is not the way to use git.
Your changes should have been done in multiple commits, precisely so that you can cherry pick the commits and be able to apply individual commits between branches.
At this point, the most practical course of action is probably to create yet another branch, stage your local commit in that branch, and reset the changes that you don't want to push to github.
It almost sounds like you've done a reset or something on your branch so that the branch and master files are the same, which is why git is indicating that there is no diff.
Edit: May I suggest using a UI rather than command line git, until you've got the hang of things? They'll usually have good diff clients, and can set things up slightly more easily.
Git Extensions: http://gitextensions.github.io is pretty minimal but functional.
Source Tree: https://www.sourcetreeapp.com I've heard recommended
The git client built into Visual Studio is probably too bare bones at this time, but it's there.
More to this point, you want to commit "concepts" rather than "patches" with git and version control in general. Branches are "patches" so to speak, but commits are more like "fixed item #135015" that you'd see in patch notes.
For the record, the branch and master are not the same; I have confirmed this. Fortunately this is a really small personal project (figured I might as well try to learn git while I was at it), so I can save the files, scrap the repository entirely, and try again.
edit: @Bowen, I tried using the UI, but there was no explanation for what the various options did other than their names, so I went back to command line. I need a good reference that goes beyond "here's what this does," to "...and here's what that means in practical terms." I understand the basics - I think - but it seems like every command has a ton of poorly explained options.
I picked up this book a few years ago, it might help you out:
https://www.amazon.com/Pragmatic-Guide-Git-Guides/dp/1934356727/
This one might be better though:
https://www.amazon.com/Learn-Version-Control-step---step-ebook/dp/B00K54OL8I
Plus, pretty commit/branch art.
Let's play Mario Kart or something...
Edit: autocorrect