Local repository with Git

久未见 提交于 2021-02-08 08:19:02

问题


I would like to use Git in my local computer such that, H:\Projects\projectname will be my server-like repository and I would like work by cloning this repo to C:\Users\xxx\AptanaProjects\projectname

How can I do that ?

Thanks


回答1:


First you need to create a bare repository on H:. With git you usually name your bare repository with .git, so projectname.git in this case:

h:
cd \Projects\
mkdir projectname.git
cd projectname.git
git init --bare

When this is done you change to c to create your repository:

c:
cd \Users\xxx\AptanaProjects\projectname
git init
git add .
git commit -m "First commit"

After this you need to setup the bare repo on h: as the remote repository so you can push up the code you just commited to the repo on c:

git remote add origin H:\Projects\projectname.git
git push origin master

Now, someone else can clone from H: to get your changes, and their repos will automatically be setup with the repo on H: as their origin.




回答2:


  1. Install Git if you haven't already
  2. With e.g. TortoiseGit, initialize a repository in H:\Projects\projectname ("Git create repository here" in the context menu)
  3. Clone that repository to your working directory, e.g. C:\Users\xxx\AptanaProjects\projectname ("Git Clone..." in the context menu)
  4. You're done.

Now when you work, commit in your working directory and then Git Push to send your changes to H:\ Projects.

I'm assuming you have a valid reason for having that projects directory and not just versioning your projects in the working directory?




回答3:


Enter directory C:\Users\xxx\AptanaProjects\projectname and use:

git clone H:\Projects\projectname

or using file protocol file://

Look at http://progit.org/ for free documentation.



来源:https://stackoverflow.com/questions/6355139/local-repository-with-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!