Club PA 2.0 has arrived! If you'd like to access some extra PA content and help support the forums, check it out at patreon.com/ClubPA
The image size limit has been raised to 1mb! Anything larger than that should be linked to. This is a HARD limit, please do not abuse it.
Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

Git beginner help

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.

Jedoc wrote: »
The GOP cares about babies until they're born, soldiers until they're in need of care, and families until they interfere with stockholder dividends.

Posts

  • ecco the dolphinecco the dolphin Registered User regular
    So did you want to cherry pick commits?

    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"?

    Penny Arcade Developers at PADev.net.
  • CalicaCalica Registered User regular
    Not quite:
    • I have a master repo in github
    • I downloaded this locally
    • I branched locally
    • I made some modifications I want to keep ("fixes") and some I don't ("bugs")
    • I applied all of the changes in a single commit

    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.

    Jedoc wrote: »
    The GOP cares about babies until they're born, soldiers until they're in need of care, and families until they interfere with stockholder dividends.
  • BarrakkethBarrakketh Registered User regular
    edited August 2016
    Calica wrote: »
    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.
    The docs should help. You might need to double check the settings for winmerge. The link you posted is a few years old, and if you're using Cygwin the latest comment has some modifications.

    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.

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • CalicaCalica Registered User regular
    Barrakketh wrote: »
    Calica wrote: »
    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.
    The docs should help. You might need to double check the settings for winmerge. The link you posted is a few years old, and if you're using Cygwin the latest comment has some modifications.

    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.
    Turns out winmerge is automatically supported in Git now. Derp. But as to actually comparing files...

    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?

    Jedoc wrote: »
    The GOP cares about babies until they're born, soldiers until they're in need of care, and families until they interfere with stockholder dividends.
  • ecco the dolphinecco the dolphin Registered User regular
    edited August 2016
    Calica wrote: »
    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.

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
    143999Smrtnik
  • bowenbowen How you doin'? Registered User regular
    Calica wrote: »
    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.

    Ladies.
  • CalicaCalica Registered User regular
    edited August 2016
    Okay, that makes sense.

    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.

    Calica on
    Jedoc wrote: »
    The GOP cares about babies until they're born, soldiers until they're in need of care, and families until they interfere with stockholder dividends.
  • bowenbowen How you doin'? Registered User regular
    yeah

    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

    Ladies.
  • CalicaCalica Registered User regular
    Thanks :)

    Jedoc wrote: »
    The GOP cares about babies until they're born, soldiers until they're in need of care, and families until they interfere with stockholder dividends.
  • syndalissyndalis Getting Classy On the WallRegistered User, Loves Apple Products regular
    I recommend using sourcetree also, it will really help you wrap your head around ther concepts until you are comfy enough to live in the CLI.

    Plus, pretty commit/branch art.

    SW-4158-3990-6116
    Let's play Mario Kart or something...
    bowenEvigilantthatassemblyguy
  • CalicaCalica Registered User regular
    Ooh, thank you! I was wondering what tool people were using to get the nice graphs.

    Jedoc wrote: »
    The GOP cares about babies until they're born, soldiers until they're in need of care, and families until they interfere with stockholder dividends.
  • RollsavagerRollsavager Registered User regular
    edited August 2016
    I know I'm a little late to the party, but this sounds like it would be pretty easily fixed by running 'git reset @^' followed by 'git add --patch'. There are gui tools that allow you to make even more granular changes (I use vim with fugitive and I think my co-workers use gitx)

    Edit: autocorrect

    Rollsavager on
Sign In or Register to comment.