Wednesday, November 21, 2012

Push new code to Github

Create new repository (push fresh code to github)

1. Execute below steps (commands) in your local first - (g
o to the folder which you want to push to github)

git init
git add .
git commit -m "Initial commit"


2. Create new repo on github (using add new repository)
e.g. MyProject - https://github.com/jpa/myproject.git

3. Again go back to your local and use below commands to push the code

git remote add [name to use for remote] [private URI] # associate local repo to the remote
git push [name of remote] master # push your repository to the remote


Sample steps for it -

git remote add origin https://github.com/jpa/myproject.git

git fetch origin #It will pull the ReadMe file from git repository which you created on it.
git merge origin/master #Merge the changes with the local files.
git push origin #push the code.


All Set :)

No comments:

Post a Comment