简体   繁体   English

使用本地环境(例如虚拟环境)设置git存储库

[英]Setting up git repository with local environment [e.g. virtual environment]

I have a directory containing files of a git repository along-with some lib and bin files file. 我有一个目录,其中包含git存储库的文件以及一些lib和bin文件。 But there is no versioning system in the folder(no .git folder). 但是文件夹(没有.git文件夹)中没有版本控制系统。

How do I setup git repository for my local use, which is in sync with remote git repository along with bin-files which already exist in local folder ? 如何设置git存储库供本地使用,它与远程git存储库以及本地文件夹中已经存在的bin文件同步?

You can initialize a new git repository by typing git init within your working directory. 您可以通过在工作目录中键入git init来初始化新的git存储库。

This will create the .git directory. 这将创建.git目录。 Then you need to tell git where the remote is, so go to github.com and create a new repository. 然后,您需要告诉git远程位置,所以转到github.com并创建一个新的存储库。

When you create it go to your working directory and type: 创建它时,请转到您的工作目录并键入:

git remote add origin https://github.com/user/repo.git

and replace user and repo with the appropriate fields. 并用适当的字段替换用户和仓库。

The first thing you ll have to do is create your initial commit. 您要做的第一件事是创建您的初始提交。 Typically the initial commit is the README file: 通常,初始提交是自述文件:

touch README.md
git add README.md
git commit -m "Initial commit"
git push origin master

After you do that, your README file should appear on github.com under the repository you created. 完成之后,您的自述文件应显示在github.com上您创建的存储库下。

The next step is push your current bin-files to remote. 下一步是将您当前的bin文件推送到远程。 Assuming you want to track all of the files in your working directory do this: 假设您要跟踪工作目录中的所有文件,请执行以下操作:

git add . which will add all of your files in version control. 它将在版本控制中添加所有文件。

Then commit your changes git commit -m "Your commit message" and push them to the remote git push origin master . 然后提交您的更改git commit -m "Your commit message" ,并将其推送到远程git push origin master

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

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