Wednesday, April 22, 2015

Adding an existing project to GitHub

1. Go to the project directory and run the command 'ls -al' to see .git directory exist in your project or not, if it is not exist then run the below command.

git init

You can see .git directory is created in your project directory.

2. Then by running 'git status' command, you can see the files. You have to add these files to git

git add .

3. then you have to commit

git commit -am "my first commit"

4. Now you have to add remote to your project but first you need to create repository in Github.
Go to Github and create repo.

5. Now you have to add a remote, you can see the remote by 'git remote -v' command.

git remote -v
// display empty result

You can add remote by following command.

git remote add origin address_of_remote_repo

Now run

git remote -v
// you will see the remote url

6. Now you need to pull master from your project.
Run below command

git pull origin master

7. Last you need to push your files to Github repo.

git push -u origin master

2 comments: