简体   繁体   English

创建本地git存储库而不是使用github

[英]Creating a local git repository instead of using github

I know that in project x you can do git init but what about creating a place to push too locally? 我知道在项目X中可以执行git init但是如何创建一个过于本地化的地方呢? So for example I use drop box and I want to create a git repo there that I can do git push drop-box 因此,例如,我使用投递箱,我想在那里创建一个git repo来执行git push drop-box

I did: git init --bare in the drop box folder and then tried doing: 我做了: git init --bare在投递箱文件夹中,然后尝试执行以下操作:

git add remote origin "/Users/Adam/Documents/rpg maker/the-child-and-the-poet-repo/"
fatal: /Users/Adam/Documents/rpg maker/the-child-and-the-poet-repo/: '/Users/Adam/Documents/rpg maker/the-child-and-the-poet-repo/' is outside repository

But as you can see this didn't work. 但是如您所见,这没有用。 Ideas? 有想法吗?

The link I provided in the comment above is the way to go for DropBox, but I thought it might be useful to have a more general set of instructions for creating a local Git repository, so here it is. 我在上面的注释中提供的链接是使用DropBox的方法,但是我认为使用一组更通用的说明来创建本地Git存储库可能会有用,所以就在这里。

You can initialize a local Git repository with just three commands. 您仅需三个命令即可初始化本地Git存储库。 From your C:/ drive (on Windows) type: C:/驱动器(在Windows上)中键入:

mkdir newrepo.git
cd newrepo.git
git init --bare

Now you can clone a copy of your local repository to another local location: 现在,您可以将本地存储库的副本克隆到另一个本地位置:

git clone C:\newrepo.git newrepo

The git clone command will clone newrepo into a directory called /newrepo . git clone命令会将newrepo克隆到一个名为/newrepo的目录中。 It will initialize a .git directory inside of it, and pull down the entire repository content. 它将在其中初始化一个.git目录,并下拉整个存储库内容。 In addition, it will check out a working copy (usually master ), and this is the branch on which you will begin. 此外,它将签出工作副本(通常是master ),这是您将开始的分支。

You are now ready to start working, and all the usual Git commands are fair game from this point forward. 现在您可以开始工作了,从现在开始,所有常用的Git命令都是公平的游戏。

Please have a look at this great blog for more information. 请查看这个很棒的博客以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM