I would really encourage you to get used to working inside the one directory. Git is on-purpose designed for this.
If the reason you're doing this is because you can't immediately tell what branch you're on by using something other than the directory name, then I would encourage looking into things that set your prompt to include the branch name. I have something like this in my personal dot files (bash prompt setting here and __git_ps_1
command here.
This has saved me so many times it's worth its weight in gold.
Now that we've got the multiple directories problem solved, you should read this great post called "A successful Git branching model" that covers using several different branches for development, albeit on a single repository.
Once you're done there, now you're ready to apply this same thing to other repositories. First, you're going to need to add the remote repository to the list of remotes tracked by git. This is just helpful as you can reference by name rather than address, with the name generally being much shorter than the address.
git remote add main git@github.com:organization/main.git
I am going to assume here that the remote is what has this release
branch on it. The first thing you're going to want to do here is update the information about this repository, which you can do with this command:
git fetch main
If you're working with multiple remotes (which would indicate some level of insanity on your part), you can fetch them all with git fetch --all
.
Anyway, once you've done that initial fetch, you can then checkout main
's release
branch into your repository:
git checkout main/release -b release
This tells git, "Hey, get me main/release's branch, and call it release in this repository (please)".
Now, assuming that you've been a good developer, you should be able to directly merge your commits across into this branch from your master
branch. Right now, you'll be in the release
branch that is based off main/release
so you'll just need to do this:
git merge master
Some people here would ask you to rebase
instead (There's an interesting discussion about this here. That has the same syntax as merge: git rebase release
.
Now you need to really really make sure that everything's working as it should. That's up to you.
Once you're super-confident about that, you can push your release
branch to the main
repository by running this command:
git push main release
Now go forth and Git :)