Creating a Repository on GitHub



In this post we learn how to create a repository on GitHub, clone the repository, get the status, add files, commit code, push code, and pull down other code changes from the repository.

Step 1: Setup a GitHub account and create a Repository

Once you are logged into GitHub. Click on the “New Repository” button. First, give the repository a name. Then select either “Public” or “Private” depending on who should be able to see this repository. Check the “Initialize with README” checkbox and click “Create Repository”. Now, on our repository home page, click on the “Clone or Download” button and copy the link to the repository.

Step 2: Command Line Git commands

1. Open up the command line and use the following command to clone the repository that was just created in step 1. The git clone command will clone everything in the repository on GitHub.com into the servers folder you run this command inside.

git clone git@github.com:jstolpe/github_tutorials.git

2. Add an index.php file inside of the repository we just cloned. Run git status to get the status of the repository on the localbox compared to the repository on GitHub. After running this command, the index.php should show up in red and the command line should state that index.php is an underacted file.

git status

3. Add the file so it is ready to be committed with the git add command. This file basically marks the file as ready for commit.

git add --all

4. Our index.php file is ready to commit at this point with the git commit command. We will be adding a commit message along with this command so when we view the commit log, we can see our comment letting us know the purpose of this commit.

git commit -m "adding index.php to the repository"

5. Before the file actually goes up to the GitHub repository we have one command left to run, git push. This will sent our file up to the repository along with our commit message.

git push

6. Lastly, if others developers have been making changes to the same repository, we want to grab those changes and make sure we have them on our local box. This way we are up to date with the latest and greatest. To do this we run the git pull command. If we already have everything, we should see an “Already up to date” message in the command line. Otherwise, we will see all the new files and updates displayed in the command line after running git pull.

git pull

That is going to do it for the very basics of creating a repository. A few tips I have would be to run git status, alot. This way you can quickly check to see if anything locally differs from the repository. Also, run git pull before you begin working. This will make sure you have the latest and greatest code in the repository before starting in on a new feature. If you do not do a git pull before starting a new feature, and there have been many other developers who have committed lots of updates, you are not starting with the most recent, up to date repository. In this case, you run the risk of many merge conflicts when you are ready to commit your code.

Links

YouTube Video

Code on GitHub

That is going to do it for this post! Leave any comments/questions/concerns below and thanks for stopping by the blog!

205 comments

  1. hey tthere and thanhk youu for your innfo –
    I’ve certainly picked uup anytging neww from right here.
    I did however expedrtise sveral technical isssues usig this website,
    aas I ecperienced to reload tthe website lotts of times previous
    to I could gett iit to lad correctly. I hhad been wondering if your web hosxt is OK?
    Noot that I’m complaining, but sloow loading instancess times will sometimes affdect your poacement in glogle
    annd cann damage yor hiogh quality sscore if ads and
    marketinjg wwith Adwords. Well I’m adding tthis RSS to myy e-mail annd can look outt ffor a lott mmore
    of your reswpective intrijguing content. Make ssure youu updwte this agan soon.

  2. This is a good tip especially to those new to the blogosphere. Brief but very precise infoÖ Many thanks for sharing this one. A must read article!

  3. I’ll right away take hold of your rss feed as I can not to find your e-mail subscription link or e-newsletter service. Do you have any? Please permit me understand in order that I may subscribe. Thanks.

  4. Good day! This is my first visit to your blog! We are a group of volunteers and startinga new project in a community in the same niche.Your blog provided us valuable information to work on. Youhave done a extraordinary job!

  5. Heya i’m for the first time here. I came across thisboard and I to find It really useful & it helped meout a lot. I hope to provide one thing again and aid others like you helped me.

  6. Hello! I could have sworn I’ve been to this blog before but after reading through some of the post I realized it’s new to me. Anyhow, I’m definitely glad I found it and I’ll be book-marking and checking back frequently!

  7. I need to to thank you for this fantastic read!! I definitely enjoyed every little bit of it. I’ve got you book marked to check out new things you postÖ

  8. Hey there! I could have sworn I’ve been to this blog before but after checking through some of the post I realized it’s new to me. Nonetheless, I’m definitely glad I found it and I’ll be bookmarking and checking back often!

  9. Hi there! I could have sworn I’ve been to this blog before butafter checking through some of the post I realized it’snew to me. Anyhow, I’m definitely glad I found it and I’llbe bookmarking and checking back often!

  10. Hi, I do believe this is a great blog. I stumbledupon it 😉 I will revisit once again since i have saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

  11. Generally I don’t read post on blogs, howeverI wish to say that this write-up very pressured me to check out and do so!Your writing taste has been amazed me. Thank you, very nice article.

  12. Thank you for sharing your personal story with your readers, Brendan. These photos and stories are so fun to look at and to enjoy vicariously through your blog. Good luck in your upcoming travels.

  13. You can certainly see your enthusiasm in the work you write.The world hopes for even more passionate writers such as you who aren’t afraid to say how they believe.At all times follow your heart.

  14. I do believe all of the concepts you’ve offered for your post. They’re very convincing and will definitely work. Still, the posts are very quick for newbies. May just you please lengthen them a little from subsequent time? Thank you for the post.

  15. A motivating discussion is definitely worth comment. I do think that you ought to write more about this subject matter, it might not be a taboo matter but usually people do not discuss such issues. To the next! Kind regards!!

  16. Heya i’m for the first time here. I found this board and I findIt truly useful & it helped me out a lot. I hope to give something back and aid others like you aidedme.

  17. Howdy! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a extraordinary job!

  18. Good day! I could have sworn Iíve been to this blog before but after looking at a few of the posts I realized itís new to me. Regardless, Iím certainly pleased I stumbled upon it and Iíll be bookmarking it and checking back regularly!

  19. I’m really enjoying the design and layout of your blog. It’s a very easy on the eyeswhich makes it much more enjoyable for me to come here and visit more often. Did youhire out a developer to create your theme? Excellent work!

  20. Great post. I was checking continuously this blog and I’m impressed!Extremely useful information specially the lastpart 🙂 I care for such information a lot. I was seeking this certain info for a long time.Thank you and best of luck.

  21. Hey there! Would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would really enjoy your content. Please let me know. Cheers

  22. My brother recommended I might like this blog. He was totally right.This post actually made my day. You can not imagine just howmuch time I had spent for this information! Thanks!

  23. Hey there! I’m at work surfing around your blogfrom my new iphone 3gs! Just wanted to say I love reading through yourblog and look forward to all your posts! Keep up the excellent work!

  24. Excellent way of explaining, and good piece of writingto obtain data concerning my presentation subject, which i am going todeliver in institution of higher education.Also visit my blog post :: Pure Optimum Keto

  25. Hey! Do you use Twitter? I’d like to follow you if that wouldbe ok. I’m definitely enjoying your blog and look forward to new posts.

  26. Chrome-plated steel is created by dipping average steel right into an electrolyte option including chromium as well as takes advantage of electrolysis to create the finishing.

  27. I am now not sure the place you’re getting your info,however great topic. I needs to spend a while studying more orfiguring out more. Thank you for great info I was on the lookoutfor this information for my mission.

  28. I love what you guys tend to be up too. Such clever work and coverage!Keep up the very good works guys I’ve incorporated youguys to my own blogroll.

  29. 威而鋼拯救男人前的秘密故事. 2018/09/06 編輯/. 20年前,威而鋼問世,拯救了許多男人的性生活(以及他們的性伴侶)。然而,在威而剛攻佔男人們的床頭櫃-威而鋼

  30. Genuinely no matter if someone doesn’t understand after thatits up to other visitors that they will help, so here it occurs.

  31. Very great post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed surfing around your blogposts. After all I’ll be subscribing on your feed and I hope youwrite once more soon!

  32. Selamat datang di situs hackslotgames.com yang juga merupakan situs jasa hack atau caramenang permainan slotgames. Pasti kalian sudah pernah mendengar setidaknya permainan slotgame.

  33. Howdy! I simply wish to offer you a huge thumbs up for the excellent information you have here on this post. I will be coming back to your blog for more soon.

  34. Thanks for sharing your thoughts. I truly appreciate your efforts and I will be waiting for your next post thanks once again.

  35. Hey There. I found your blog using msn. This is a very well written article. I’ll make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I’ll certainly return.

  36. I don’t even understand how I stopped up here, but I thought this put up used to be great. I do not understand who you are but certainly you’re going to a famous blogger for those who are not already. Cheers!

  37. whoah this blog is fantastic i really like studyingyour articles. Keep up the good work! You recognize, a lot of people are searching roundfor this information, you can help them greatly.

  38. Your method of telling everything in this article is actually pleasant, every one can effortlessly understand it, Thanks a lot.

  39. An fascinating discussion is value comment. I believe that it is best to write extra on this matter, it might not be a taboo subject but typically people are not enough to speak on such topics. To the next. Cheers

  40. I appreciate, lead to I found just what I used to be having a look for. You’ve ended my 4 day long hunt! God Bless you man. Have a nice day. Bye

  41. Your means of describing the whole thing in this postis truly nice, every one be able to easily understand it, Thanks a lot.

  42. Elvis Presley The King In The Ring Buckingham Nicks Buckingham Nicks Billy Squier Emotions In Motion

  43. I read this piece of writing completely regarding the resemblance of most up-to-date and earlier technologies, it’s awesome article.

  44. It’s really a great and helpful piece of information. I’m glad that you shared this useful information with us. Please keep us informed like this. Thank you for sharing.

  45. Excellent blog you have here.. It’s hard to find high-qualitywriting like yours these days. I honestly appreciate people like you!Take care!!

  46. Your style is very unique in comparison to other folks I have read stuff from. Thanks for posting when you have the opportunity, Guess I’ll just bookmark this blog.

  47. fantastic issues altogether, you just gained a logo new reader.What could you suggest about your submit that you just made some days in the past?Any certain?

  48. Hi! I’m at work surfing around your blog from my new iphone4! Just wanted to say I love reading through your blog and look forward toall your posts! Carry on the superb work!

Leave a Reply

Your email address will not be published. Required fields are marked *