The below text contains a necessary commands on how to initialize a git repository with Github. Here we assume that you have created a new repository using your Github account and now you wish to push your project files into this new Github repository. In order tu push your files to a new Github repository we need to initialize it our new repository locally.

First, navigate to your project directory containing all files:
$ cd /my/project/directory
Then, initialize git:
$ git init
This will create a .git directory and you next ready to add remote origin. This will be the URL provided to you on Github repository page. eg. https://github.com/linuxconfig/apt-cacher-ng.git. Use your link to add remote origin:
$ git remote add origin https://github.com/linuxconfig/apt-cacher-ng.git
Perform a initial pull as there may already be some files such as License or README to merge:
# git pull -u origin master
Now, we are ready to add, commit and push our project files:
$ git add *
$ git commit -m 'Initial commit'
$ git push -u origin master
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: