Quick notes on how to create a GitHub repository for an existing project
A rough workflow for creating a repository for an existing project:
- Create a new repository in GitHub, e.g.,
example-proj - Do
git initin the project directory - If necessary, configure:
$ git config user.name "user-Name" $ git config user.email "username@example.com" $ git config credential.helper example-cred git remote add origin https://github.com/user-Name/example-proj.git$ git pull origin master- Create/edit
.gitignore - Add project files:
$ git add . - Commit changes:
$ git commit -m "added project" - Push changes:
$ git push origin master
The important point is to do git pull before adding and commiting anything, and then do add, commit, and push. If you have added and commited before pulling from the remote project, pushing will throw an error. You will have to integrate by pulling with --allow-unrelated-histories:
$ git pull origin master --allow-unrelated-histories
$ git push --set-upstream origin master