Most of the times, it makes more sense to start working on something that slowly transforms into the beginning of a project that deserves to be on github. This post is about creating a local repository and putting it on github.
1. First we must convert the main local folder into a git repository. For this example let’s call the folder “my-new-project”. With your terminal go to that folder and type:
the repository will initialize but nothing will be added to it yet. If you type git status you will see all the things you can add to it, so use git add to add the folders you want to track, and then go ahead and do a git commit -m “initial commit”
2. Now go to github.com and create your repository “my-new-project”, and copy the clone url of the repo, I personally like to work with the one that starts with “ssh://” since I like to work with ssh keys and not have to deal with passwords.
You can easily configure your ssh certificates for multiple things, not just github but keys for many many servers working with the ~/.ssh/config file (no need to deal with effing ssh-agent).
If you created this github repository with some other account, make sure to give yourself contributor access on the github role settings, otherwise you won’t be able to pull/push.
3. Time to pull (fetch+merge) the remote repo and then push this baby up.
You do that by invoking the following commands (let’s suppose the remote url is git remote add origin
git remote add firstname.lastname@example.org:myaccount/my-new-project.git git pull origin master
you should see something like below coming from the remote repo’s master branch:
warning: no common commits remote: Counting objects: 4, done. remote: Compressing objects: 100% (2/2), done. remote: Total 4 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. From github.com:myaccount/my-new-project * branch master -> FETCH_HEAD Merge made by the 'recursive' strategy. .gitignore | 6 ++++++ README.md | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 .gitignore create mode 100644 README.md
and then just
and you’re done, you should see your initial commit on github now.