{"id":3150,"date":"2013-08-31T10:55:03","date_gmt":"2013-08-31T10:55:03","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3150"},"modified":"2013-08-31T10:57:19","modified_gmt":"2013-08-31T10:57:19","slug":"how-to-add-an-existing-git-repository-to-github","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/how-to-add-an-existing-git-repository-to-github\/","title":{"rendered":"How to add an existing GIT repository to github."},"content":{"rendered":"<p>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.<\/p>\n<p>1. First we must <strong>convert the main local folder into a git repository<\/strong>. For this example let&#8217;s call the folder &#8220;my-new-project&#8221;. With your terminal go to that folder and type:<br \/>\n[bash]git init[\/bash]<\/p>\n<p>the repository will initialize but nothing will be added to it yet. If you type <strong>git status<\/strong> you will see all the things you can add to it, so use <strong>git add<\/strong> to add the folders you want to track, and then go ahead and do a <strong>git commit -m &#8220;initial commit&#8221;<\/strong><\/p>\n<p>2. Now <strong>go to github.com and create your repository &#8220;my-new-project&#8221;<\/strong>, and copy the clone url of the repo, I personally like to work with the one that starts with &#8220;ssh:\/\/&#8221; since I like to work with ssh keys and not have to deal with passwords. <\/p>\n<p>You can easily configure your ssh certificates for multiple things, not just github but keys for many many servers <a href=\"http:\/\/nerderati.com\/2011\/03\/simplify-your-life-with-an-ssh-config-file\/\" target=\"_blank\">working with the ~\/.ssh\/config file<\/a> (no need to deal with effing ssh-agent). <\/p>\n<p><em>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&#8217;t be able to pull\/push.<\/em><\/p>\n<p>3. Time to <strong>pull (fetch+merge) the remote repo and then push this baby up<\/strong>.<br \/>\nYou do that by invoking the following commands (let&#8217;s suppose the remote url is git remote add origin <string>git@github.com:myaccount\/my-new-project.git<\/strong>):<br \/>\n[bash]git remote add git@github.com:myaccount\/my-new-project.git<br \/>\ngit pull origin master[\/bash]<\/p>\n<p>you should see something like below coming from the remote repo&#8217;s master branch:<\/p>\n<p>[bash]warning: no common commits<br \/>\nremote: Counting objects: 4, done.<br \/>\nremote: Compressing objects: 100% (2\/2), done.<br \/>\nremote: Total 4 (delta 0), reused 0 (delta 0)<br \/>\nUnpacking objects: 100% (4\/4), done.<br \/>\nFrom github.com:myaccount\/my-new-project<br \/>\n * branch            master     -> FETCH_HEAD<br \/>\nMerge made by the &#8216;recursive&#8217; strategy.<br \/>\n .gitignore | 6 ++++++<br \/>\n README.md  | 2 ++<br \/>\n 2 files changed, 8 insertions(+)<br \/>\n create mode 100644 .gitignore<br \/>\n create mode 100644 README.md[\/bash]<\/p>\n<p>and then just<br \/>\n[bash]git push[\/bash]<\/p>\n<p>and you&#8217;re done, you should see your initial commit on github now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15],"tags":[1437,484,1331,533,1024],"class_list":["post-3150","post","type-post","status-publish","format-standard","hentry","category-code","tag-code","tag-git","tag-github","tag-howto","tag-tutorial"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-OO","jetpack-related-posts":[{"id":3055,"url":"https:\/\/www.gubatron.com\/blog\/my-git-cheat-sheet\/","url_meta":{"origin":3150,"position":0},"title":"My Git Cheat-sheet","author":"gubatron","date":"May 28, 2013","format":false,"excerpt":"I don't know if it's the crazy syntax, but for the life of me, I always need to come back to this cheat sheet, maybe you will too: GIT CHEATSHEET fetch remote branch. git fetch origin nameofbranch \"fetch\" downloads the changes of the remote branch but doesn't automatically merge them.\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2016-01-02-at-4.40.11-PM.png?fit=1200%2C696&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2016-01-02-at-4.40.11-PM.png?fit=1200%2C696&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2016-01-02-at-4.40.11-PM.png?fit=1200%2C696&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2016-01-02-at-4.40.11-PM.png?fit=1200%2C696&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2016-01-02-at-4.40.11-PM.png?fit=1200%2C696&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2068,"url":"https:\/\/www.gubatron.com\/blog\/bitbucket-or-github\/","url_meta":{"origin":3150,"position":1},"title":"Bitbucket or Github?","author":"gubatron","date":"September 28, 2010","format":false,"excerpt":"This week we have to make a final choice of what technology will be used to replace our somewhat big subversion repository (2 Gigs). Huge imports are beginning to be a pain and we're tired of the .svn folders and not being able to commit if the central server is\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4122,"url":"https:\/\/www.gubatron.com\/blog\/screw-configuring-gpg-to-sign-git-commits-do-it-with-your-same-ssh-key-like-this\/","url_meta":{"origin":3150,"position":2},"title":"Screw configuring GPG to sign git commits, do it with your same SSH key like this","author":"gubatron","date":"January 30, 2025","format":false,"excerpt":"GPG gives a lot of shit on macos for some reason. It's best to just add the same SSH authentication key you have on github as a \"Signing Key\" in your github account signing configuration. Go to Settings > SSH and GPG Keys You can then configure your github client\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2025\/01\/ssh_sign.jpg?fit=736%2C441&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3001,"url":"https:\/\/www.gubatron.com\/blog\/how-to-gpu-mine-bitcoins-on-a-macbook-pro\/","url_meta":{"origin":3150,"position":3},"title":"How to GPU-mine BitCoins on a MacBook Pro","author":"gubatron","date":"April 27, 2013","format":false,"excerpt":"I've just gotten started into BitCoin a little late in the game (April 2013) and if you're reading this you're probably on the same boat. This post details the steps I took to start mining BitCoins with GPU on a MacBook Pro. 1.\u00a0Get DiabloMiner. You will need to have installed\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"4195093260_78f080cab0_z","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/04\/4195093260_78f080cab0_z.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/04\/4195093260_78f080cab0_z.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/04\/4195093260_78f080cab0_z.jpg?resize=525%2C300 1.5x"},"classes":[]},{"id":3313,"url":"https:\/\/www.gubatron.com\/blog\/solved-sublime-text-2-git-binary-could-not-be-found-in-path\/","url_meta":{"origin":3150,"position":4},"title":"[SOLVED] Sublime Text 2: Git binary could not be found in PATH","author":"gubatron","date":"July 22, 2014","format":false,"excerpt":"Got this annoying dialog popping up on Sublime Text 2? Go to Preferences > Browse Packages ... a Finder window will open, go to the \"Git\" folder, open the file called \"Git.sublime-settings\" Look for \"git_command\" and set it's value to the path of your git executable (you can find the\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"Screen Shot 2014-07-22 at 4.31.03 PM","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/07\/Screen-Shot-2014-07-22-at-4.31.03-PM.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3646,"url":"https:\/\/www.gubatron.com\/blog\/git-how-to-replace-your-master-branch-with-another-branch\/","url_meta":{"origin":3150,"position":5},"title":"[GIT] How to replace the master branch with another branch.","author":"gubatron","date":"January 3, 2017","format":false,"excerpt":"TL;DR; git checkout master git reset --hard fixed-master-branch git push origin master -f Sometimes someone may pollute the 'master' branch and you may have noticed this only after you've fetched, rebased and pushed your commits. So your history may end up like this (I'll use decimal numbers on the commit\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3150"}],"version-history":[{"count":4,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3150\/revisions"}],"predecessor-version":[{"id":3155,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3150\/revisions\/3155"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}