Monday, July 21, 2014

Associating a Local Git Repository To A Remote Github Repository

One of the things that gets me really frustrated while trying to learn something new and wanting to save my practice code in Github so as to:

  • Not lose them and have them for reference whenever I need it.
  • So as to be able to access them anytime I needed them
is that I have to mess around with Github + Egit + Eclipse for much longer than actually learning/writing something new.

In any case, here's a common mistake that I've been doing and see lot of my peers do when starting to work with Git and Git hub and that is when wanting to associate a remote Github repository with a local git repository created using  
  • Egit plugin for eclipse
  • Using the git init command from the terminal 
it is incorrect to execute the git remote add command from any other place other than the local git repo directory [the one containing .git folder]

Here's the steps that I normally take:
  1. Create a remote Github repository such as Messing-With-Python
  2. Create a local git repository on my computer FirstPythonProject
  3. Execute the following in the terminal from the FirstPythonProject [This directory should have a .git hidden directory]
git remote add origin https://github.com/<username>/Messing-With-Python.git