Hosting a git server on localhost

前端 未结 3 1732
我寻月下人不归
我寻月下人不归 2021-02-07 12:38

My company does not have a central git server, and neither do they allow me to use BitBucket etc.

Is there anyway I can use my localhost as remote ?

<
3条回答
  •  余生分开走
    2021-02-07 13:19

    Local directories work just like remote repository URLs, so basically there's nothing you need to do as long as you're the only person using the repository.

    Example, assuming Git Bash (from msysgit):

    mkdir /c/git
    mkdir /c/git/testrepo.git
    cd /c/git/testrepo.git
    git init --bare
    cd $TEMP
    git clone /c/git/testrepo.git
    cd testrepo
    # hackety hack
    git add .
    git commit -m "I shouldn't be making commits like this but who's gonna sue me"
    git push origin master
    cd ..
    git clone /c/git/testrepo.git testrepo2
    cd testrepo2
    # wow, all my files are here
    

    That said, just creating a normal local repository with git init gives you a complete Git repository in which you can make commits and everything, and which you can clone and merge/pull from. Most of the time, this is really all you need.

提交回复
热议问题