简体   繁体   English

连接和克隆远程git仓库之间的区别

[英]Difference between connecting and cloning remote git repository

I have create a new project with GitHub and have Eclipse IDE for Java Developers in my local machine. 我已经使用GitHub创建了一个新项目,并且在本地计算机上具有针对Java开发人员的Eclipse IDE。 Creating a new GitHub project creates a new repository which is empty and I can clone it to my local machine. 创建一个新的GitHub项目会创建一个新的存储库,该存储库为空,我可以将其克隆到本地计算机上。

Then I add a new Eclipse Java project using as default location the folder of the empty repository (It only contains .git folder) I have just cloned from GitHub. 然后,使用刚从GitHub克隆的空存储库的文件夹(仅包含.git文件夹)作为默认位置,添加一个新的Eclipse Java项目。 Adding new Java project means some folders are just added to the repository. 添加新的Java项目意味着会将一些文件夹添加到存储库中。 Then I commit and push the new files to remote. 然后,我提交并将新文件推送到远程。

My teacher told me this way is wrong way to proceed. 我的老师告诉我,这种方式是错误的前进方式。 He says I should create a new Java project first (in a local folder not tracked by git) and then use the >> team >> share project contextual menu and make the project a repository. 他说我应该先创建一个新的Java项目(在git不能跟踪的本地文件夹中),然后使用>> team >> share项目上下文菜单并将该项目作为存储库。 Then I do the commit and after that I should connect it to the remote GitHub repository and do the push. 然后执行提交,然后将其连接到远程GitHub存储库并进行推送。

I don't understand the difference between the two ways to proceed. 我不了解两种进行方式之间的区别。 Indeed I think I dont understand very well the meaning of add a new remote. 确实,我认为我不太了解添加新遥控器的含义。 Could I connect any local git repository to remote git repository and push changes?. 我可以将任何本地git存储库连接到远程git存储库并推送更改吗?

Both workflows would ultimately end up with the same state. 两种工作流程最终都将以相同的状态结束。 So there is no wrong way to do this. 因此,没有错误的方法来执行此操作。 The difference between the two given workflow deals with what files Eclipse initializes the initial repository. 两种给定工作流程之间的区别在于Eclipse初始化初始存储库的文件是什么。 There is a file named .gitignore which Eclipse may include in the initial repository which prevents git from tracking certain eclipse specific files. Eclipse可能在初始存储库中包含一个名为.gitignore的文件,该文件可防止git跟踪某些Eclipse特定文件。 If Eclipse does the initial configuration on your behalf then that is less you would have to worry about. 如果Eclipse代表您进行初始配置,那么您不必担心。

To directly answer your question, each git repository is a self contained version of the history of the project. 为了直接回答您的问题,每个git存储库都是项目历史记录的独立版本。 Remotes are an abstraction that tells Git where another repository is located. 远程是一种抽象,它告诉Git另一个存储库在哪里。 This means that there is no authoritative or master repository and any clone or new repository can communicate with any other. 这意味着没有权威或主存储库,任何克隆或新存储库都可以与任何其他存储库进行通信。

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

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