Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking on a Git feature branch and use(?) branch at the same time
    text
    copied!<p>I'm new to Git, and sometimes I find myself working on a feature branch(say adding library A) while also working on program B that uses it(which I call the use branch, maybe there is a better word). So what I've done in the past is have two separate branches, work on the feature branch 'til it seems like it might work, then start using the API in the use branch, merge the feature branch in and see if it works. If it doesn't work, I go back to the feature branch, fix the issue, merge and repeat. Is this the best way to do this?</p> <p>My goal is to keep the feature branch separate from any implementation that uses it(though I suppose even that is up for debate). What I also thought of later is presuming I'm editing a limited number of files I could just do the 'fixing' changes in the use branch and use 'git checkout' in the feature branch to bring just the library changes back in.</p> <p>What I guess I really want is to be working in a single workspace, but specify that these files belong to branch A and these files belong to branch B and be able to commit them separately. (I can imagine an implementation where you specify 2(or n) branches to combine into a pseudo branch, presuming that you don't alter the same files. Then when you change files that are in one branch you can commit just those files to that branch(and if you modify new files, you have to specify which branch this file 'belongs' to)). For all I know this may be in opposition to how Git works, but I don't know it enough to tell. :)</p> <p>Thoughts?</p> <p>Clarifications/Addendums: <li>This is a single program in one repository(though two repositories may be the solution)</li> <li>There are two branches I'm currently working with</li></p> <p>Example(not actually what I'm doing :)): I'm writing a program to generate a random number and then write it to a file. So my main program is in its own branch(what I refer to as my 'use' branch). My main program is simply:</p> <p>MyFileApi::Write("myfile", random());</p> <p>where random() is some system API that already exists, but MyFileApi::Write is a new feature I'm developing(so my program is using this new feature). In my 'feature branch' I have say a header file and implementation for MyFileApi::Write. So I've written some implementation of MyFileApi::Write, but I want to test it using my new random-number-file-writer program(it would probably be best to write tests specifically for this API, but I'm being lazy and testing it in my program that uses the code). So what I've been doing is merging in my MyFileApi::Write changes into my 'use' branch, testing it, seeing it fail, going back to my feature branch, fixing the issue, merging again, repeat etc...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload