Skip to content

Instantly share code, notes, and snippets.

@yati-sagade
Last active December 16, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yati-sagade/5389659 to your computer and use it in GitHub Desktop.
Save yati-sagade/5389659 to your computer and use it in GitHub Desktop.
Say your code resides in a dir called project/ locally and you want to push it up to an empty repo on github. Then, if your repo is called, say, foo, get its URL, e.g., https://github.com/sneha/foo.git and do
git remote add origin https://github.com/sneha/foo.git
from your project/ dir. After that, add files using `git add`. Use the followinng for all files:
git add .
Then commit changes
git commit -m "initial commit"
Now do
git push origin master
assuming you have just a single branch master. Otherwise, just replace master with whatever branch you want to push to.
After this when you make changes, add those files using `git add file1 file2...`, commit and push.
Another scenario is that you created the repo first and cloned it and added files and now want to push. If this is the case, skip the first step of adding a remote - just add what you want, commit and push.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment