I have repository in GitHub. I edited files in my PC, committed them and now I want to push these files to GitHub. How can I do it?
Asked
Active
Viewed 9,297 times
2 Answers
5
If the files are already cloned from a github repository git push
will do it.
cd /path/to/repo
git push
If this local repo does not belong to any github repo, create a repository in github. This will give you a git repo url like git://github.com/username/project.git
. Now you need to add this url as remote to your existing local repository
cd /path/to/repo
git remote add origin git://github.com/username/project.git
Then you can commit your changes and push it
git push

Shiplu Mokaddim
- 56,364
- 17
- 141
- 187
-
I wrote git push, but there is an error: ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:ziyaddin/git-loader.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. – Ziyaddin Sadigov Jan 01 '13 at 11:30
-
Issue a git pull first. It'll merge the repo then you can continue as usual. see http://stackoverflow.com/questions/1713137/github-first-push-problem-how-to-merge-remote-changes and http://stackoverflow.com/questions/3945080/rejected-git-push – Shiplu Mokaddim Jan 01 '13 at 11:41
-
thanks a lot! I used git add
to remove error, and then I tried git push and it done. :) Thanks very much! – Ziyaddin Sadigov Jan 01 '13 at 12:35
0
Go to github and create a repository under your account (if you haven't already). If you've done that, follow the instructions for pushing code from an already existing repository.

Femaref
- 60,705
- 7
- 138
- 176
-
yes, I already have a repository. What command I must use to push changes to GitHub? – Ziyaddin Sadigov Jan 01 '13 at 11:24