问题
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:
- Install Git if you haven't already
- With e.g. TortoiseGit, initialize a repository in
H:\Projects\projectname
("Git create repository here" in the context menu) - Clone that repository to your working directory, e.g.
C:\Users\xxx\AptanaProjects\projectname
("Git Clone..." in the context menu) - 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