Go to github and select “New Repository”

new repo

Enter the name of your repository (this needs to be unique to your github profile)

2016-04-13_21-17-47

Click “Create Repository”

Screen Shot 2016-04-13 at 8.50.38 PM

TIP: When you create a repo in Github, they basically give you the step by step instructions required at the local command line to initiate a new local repo and push it up to github:

2016-04-13_21-18-17

Go to your PC/Mac and fire up a command line…

Navigate into the directory of your software project:

2016-04-26_20-36-05

Initialise you local git repo (if there isn’t one).

git init

This command initiates a new local git db that is used for managing your source code, you should see a successful initiation message as detailed below:

gitinit

If you type the following, you'll see the current status of your local git repository:

git status

2016-05-03_20-57-18\

This shows us that while the repository has been initiated, none of the files (and directories), are being "tracked". This means they are not under git version control. To rectify this, issue the following command to add all files (and directories), for git tracking:

git add .

Get the status of your repository now and you will see that all files are being tracked:

2016-05-03_21-02-29

We now need to "commit" the changes we've made, (in this instance it's just adding all files to git version control), by issuing the following command, (the -m is message flag that allows us to add comments for this commit, this helps us track which files have been affected by a particular commit).

git commit -m "This is our first commit"

2016-05-03_21-07-42

Follow this with another status report on our repository (git status), and you should be told that there is nothing more to commit, and the working directory is clean...

At this stage our local git repository is up to date, (and if you were just a lone developer using git for version control you'd be "done"). However our local git repository is still not "associated" with the remote repository we created on github, (git and github are different things so don't confuse them!).

To make that association between your local git repository and the remote repository, type the following at your command line, (your's will look slightly different depending on the name of the repository you created on github):

git add remote origin https://github.com/binarythistle/aggregator.git

TIP: Remember the kind info the folks at github gave you when you created your github remote repository (see above)? Well this just the 2nd to last line.

Finally, issue the "push" command to push your local git repository to your newly associated github repository:

git push -u origin master

You'll be asked to authenticate to github when you perform a remote push...

Once the push is finished you're done! Both repositories, (local git and remote github are in sync).

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s