MABC MABC - 1 year ago 106
Git Question

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. Creating a new GitHub project creates a new repository which is empty and I can clone it to my local machine.

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. Adding new Java project means some folders are just added to the repository. 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. Then I do the commit and after that I should connect it to the remote GitHub repository and do the push.

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?.

Answer Source

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. There is a file named .gitignore which Eclipse may include in the initial repository which prevents git from tracking certain eclipse specific files. If Eclipse does the initial configuration on your behalf then that is less you would have to worry about.

To directly answer your question, each git repository is a self contained version of the history of the project. Remotes are an abstraction that tells Git where another repository is located. This means that there is no authoritative or master repository and any clone or new repository can communicate with any other.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download