Search code examples
gitgit-pushgit-cloneatlassian-sourcetreegit-config

Create both remote and local git respositories on same system?


I am having trouble with this. What I am trying to do is create a central git repository locally and then clone it to make a working copy. When I make changes to the clone and push the changes, I do not get any error in SourcTree but the changes does not get pushed. I don't see the change in the Central Repository.

I was getting various errors in the process, for example, SourceTree would complain this it executed git status on centeral repository

fatal: This operation must be run in a work tree [duplicate]

I have to made my center repository bare, so that error goes away but still can't get push to work. I am not sure what is causing the problem. I experimented with it a bit but not successful. Is this something doable? Am I doing something fundamentally wrong.

(I do not to use host my central repository on clouds but I can move it to a difference PC. But I really want it both (Center and Working copy) on my own system)


Solution

  • Git happily supports what you with to do. Follow these and I hope you dont get any problems:

    1. Make your central repository bare (must)
    2. List item
    3. Clone this central repo on you system elsewhere. Use the absolute/relative paths central while cloning avoid using git://.
    4. Do your work on local and push to bare.
    5. If you want to see changes there are certain restrictions in git that you 'cant't' do in bare repo. So to see changes do a git-log or see it in gitk or source tree. You will see your changes. (Or you can clone your central after push, it will have your pushed changes)