1

My Windows Computer: Has a local git repository (R1) for a Visual Studio project. The remote (origin) for this repository is GitHub. They are identical with just a Master branch. (All of the commits have been pushed to GitHub.)

NAS (local y: drive): Has an unused git repository (R2) that was created "init --bare" and nothing else has happened here.

What I would like to do (I think) is have the R2 the origin remote of R1, and GitHub the origin remote of R2. Development would occur in R1 (or other R1.x on different PCs) with commits pushed to R2. When it makes sense, the R2 branch(es) would be pushed to GitHub.

What I am not exactly sure about is how I get from where I am to where I want to be without making a mess of things. Any help/direction would be most welcome. Thanks, Jon

Jon
  • 29
  • 6

1 Answers1

0

On your R1 repo: git remote set-url origin path_to_R2

On your R2 repo: git remote add origin url_to_github_repo and then git fetch

Done.

kaman
  • 376
  • 1
  • 8
  • On the R2 repo: I had to use "set-url" not add because apparently "--bare" creates an empty "origin" remote. Also, "git diff origin/master master" works in R1 but gives the following error in R2: fatal: ambiguous argument 'master': unknown revision or path not in the working tree. Not sure if this is a problem or not. – Jon May 14 '14 at 16:40
  • You mean `--bare`? This option has nothing to do with remotes. Also what do you mean empty origin remote? – kaman May 14 '14 at 16:42
  • yes i meant --bare...a typo which i fixed. do "git init --bare" in an empty folder followed by "git remote -v" and you get "origin" as a response and also "git remote add origin..." fails. – Jon May 14 '14 at 17:10
  • Well you probably added it accidently because all `--bare` does is creating repo without working tree. That's it. Besides adding origin with no url by default doesn't make sense. Regarding `git diff` - the error you get is expected since you don't have a work tree in bare repo. You can diff commits on your remote branches though (e.g. `git diff origin/master origin/master^`) – kaman May 14 '14 at 17:25
  • Before I posted the first comment, I did "git init --bare" in an empty folder and the behavior is as I described it. I don't think I did anything to create an empty origin. It might not make any sense, but I have seen it twice now. "git diff": got it. – Jon May 14 '14 at 18:33
  • I just can't get this to work. If I instead do "git clone --bare " in R2 then the repo in R2 appears ok ("git log", "git branch -a" ... work), but the R1 repo shows all the files as untracked. I am now truly lost... – Jon May 15 '14 at 17:39