David McMillan
David McMillan

Reputation: 3

Working with two separate repos and syncing changes between them

I am a somewhat new/basic git user and I'm having a problem that I can not seem to find an answer for. I am trying to figure out a way I can store two different branches from a github repo locally on my computer. My understanding is that when I clone a repo to my laptop from Github, it also downloads all of the branch and commit history my local machine. I want to continue to use github as a version control/backup for my project. However, I am working with colleagues who understand git less than I do so I am trying to find a way to help keep everything simple for them at the same time.

Here is a description of the situation:

I can think of two ways to handle this situation but both seem to have problems that I can't see around.

Create a branch in github, make changes to the branch and then merge the branch with the master

This won't work because I am sharing the files via Google Drive and you can only have one branch of a repo on your local machine at a time. Once clone the branch to my machine, that is what gets shared via Google Drive and any changes I make disrupts everyone else's workflow.

Create a second copy of my repo, make changes there, and then push those changes to the original repo that gets shared to colleagues via Google Drive ##

I have no idea how to do this. Everything I have read discusses how to push/pull between different github users. How can I do this as a single user?

Did I forget anything important? Any help/suggestions greatly appreciated.

Upvotes: 0

Views: 76

Answers (1)

Peter Reid
Peter Reid

Reputation: 5407

You can do it all in the same directory by adding a second remote origin, if you've already added GitHub as 'origin', then run:

git remote add gdrive https://example.com/path/to/repo.git

then you can push up your changes you've made to the two repos

to push to GitHub:

git push origin

and then to push to GitHub

git push gdrive 

See this github doc page

Upvotes: 1

Related Questions