5

I have C:\Users\my\Documents\GitHub for my local GitHub repository, and C:\wamp\www is where I work on projects locally with Wampserver.

What is the appropriate setup to work with them both? Should I tell Git to use 'www' as my local repository? Will that combine localhost with Github??

shipwreck
  • 305
  • 3
  • 12

1 Answers1

5

You could simply use the --work-tree or --git-dir argument of git in order to:

  • be in the Github folder, but mention that the working tree is www

    cd C:\Users\my\Documents\GitHub
    git --work-tree=C:\wamp\www status
    
  • or be in the www folder and mention that the git repo is in the Github one

    cd C:\wamp\www status
    git --git-dir=C:\Users\my\Documents\GitHub\.git
    

The other approach is to have a git repo in both, and pulling Github from www.

    cd C:\wamp\www status
    git add remote origin C:\Users\my\Documents\GitHub
    git pull origin master
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Very succinct and easy even for me to understand! Thank you for providing multiple options – shipwreck Apr 09 '14 at 16:41
  • Would you have a preferred method in this instance? – shipwreck Apr 09 '14 at 17:02
  • @shipwreck I like the first one, because you get to manage only one Git repo. – VonC Apr 09 '14 at 19:38
  • Alright turns out im still confused... I want to fork a project on GitHub, clone it to my local repository, work on it with localhost, then make commits to the forked repository while also being able to merge commits from upstream to stay relevant with the initial project. Is this how Github is used or am I totally turned around? – shipwreck Apr 10 '14 at 03:51
  • 1
    @shipwreck no this is fine. I meant "1 *local* repo to manage", but you can link that local repo to as many upstream as you want (like your GitHub fork, *and* the GitHub original repo). See my answer about fork at http://stackoverflow.com/a/6286877/6309 and http://stackoverflow.com/a/9257901/6309 – VonC Apr 10 '14 at 05:39
  • Excellent, thank you very much. Love the feeling when that little lightbulb turns on – shipwreck Apr 10 '14 at 17:14
  • Thanks @VonC, that solution put me on the right track. But because I was using Git Bash command line on Windows, I had to change the slashes from "\" to "/" to make it work. – Georges Brisset Dec 26 '16 at 19:37