Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking on two unrelated files in separate git branches
    primarykey
    data
    text
    <p>I recently started working on a project which uses Git for version control. I have to fix two defects, <code>Defect1</code> and <code>Defect2</code>. Fixes for <code>Defect1</code> and <code>Defect2</code> need changes to <code>File1</code> and <code>File2</code> respectively. These two files are unrelated to each other. </p> <p>I want to work on each defect in a separate Git branch. I created two branches, <code>fix_Defect1</code> and <code>fix_Defect2</code>, and want to work on them independently. The fixes are complex, so I cannot complete one fix and commit it before switching to the other. I observe that when I switch from <code>fix_Defect1</code> to <code>fix_Defect2</code>, any changes made to <code>File1</code> also appear (and vice versa). Is there some way to avoid this from happening?</p> <p>From the Git help, I could not figure out any way. I also searched on SO for <a href="https://stackoverflow.com/search?q=git%20work%20with%20multiple%20branches">git work with multiple branches</a>, and found <a href="https://stackoverflow.com/questions/1334027/git-working-on-multiple-branches">Git and working on multiple branches</a> and <a href="https://stackoverflow.com/questions/12082525/using-git-with-multiple-branches-at-once">Using git with multiple branches at once</a>, which are close but somewhat different from my question. </p> <p>I can clone multiple copies of the repository per branch in a separate directory, but it seems like I would be missing the full power of Git branching by doing so, besides wasting disk space. Could you please suggest a good approach to handle this scenario? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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