I recently set up a github repository for my mod for minecraft 1.10.2, and it all works fine - I can make changes locally in eclipse, commit them and push them to github, and I can also make changes to stuff like README.md on github (to make use of its markdown previewer) and pull them to my local directory.
However, I now want to create a new branch for minecraft 1.11.2, something I've seen nearly all open-source mods do. I have got my head around how branching works now (specifically, the information in this thread), but I'm confused as to how that can play nicely with ForgeGradle. If I switch to a branch which contains 1.11.2 code, then git will fiddle with the files in my project folder (which still seems a bit weird to me, but I'm prepared to trust git not to break anything!). Surely if I then try to run it, there will be errors everywhere because eclipse will still have forge for 1.10.2 loaded up? Do I have to go through the hassle of running gradlew setupDecompWorkspace every time I switch branches? Or am I missing something?
If one of the more experienced github modders out there could tell me how they have it set up, I would be grateful!
P.S. I'm using Github desktop to do the pushing/pulling at the moment, but I'm prepared to use the command line if necessary.
The key is to only use github to store the stuff needed to build the project, not the project itself. In other words, each branch should have a build.gradle file that references the version of Forge it is working on.
Then, the next trick is you need to have multiple local repositories -- one for each version/branch. You definitely do not want to have only one local repository that switches branches.
So basically load each branch into separate local repositories, make sure build.gradle is right for each, then setup the decomp workspace in each one.
Ok, so I make two local clones of the github repository, each one contains both branches, but I only ever use the relevant branch for the relevant workspace. Then when I need to sync one of the local repositories I just pull and push that repository to github as normal.