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
That is going to do it for this post! Leave any comments/questions/concerns below and thanks for stopping by the blog!
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.
Thanks for the post. Fantastic.
Where are you living right now — the past, future or present?
Takipçi arayanlar için en kaliteli takipçiler burada. Arayanları bekleriz.
what does hydroxychloroquine treat hydroxychloroquine sulfate tablets
I am so grateful for your article.Really looking forward to read more. Awesome.
Very neat article.Really looking forward to read more. Fantastic.
I loved your post.Thanks Again. Will read on…
Really appreciate you sharing this post.Thanks Again. Great.
Appreciate you sharing, great blog post.Thanks Again. Great.
Thanks for sharing, this is a fantastic blog.Really thank you! Keep writing.
This is one awesome article post.Really looking forward to read more. Keep writing.
Thanks again for the article.Much thanks again. Cool.
Major thankies for the blog article.Really looking forward to read more. Want more.
Hello! I merely wish to give you a large thumbs up with the excellent information you have here about this post. I am coming back to your blog post for much more soon.
cancer medications tamoxifen tamoxifen vs raloxifene nolvadex indication
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!
Thanks so much for the blog article.Really looking forward to read more. Want more.
best in ottawa[…]The details talked about within the article are several of the most effective accessible […]
I truly appreciate this article post.Thanks Again. Fantastic.
Thank you ever so for you blog post. Want more.
wie bitcoin verdienenbitcoin for live 43b4135
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.
This is really helpful post and very informative there is no doubt about it.
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!
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.
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!
A round of applause for your blog.Thanks Again. Awesome.
I want to to thank you for this very good read!! I absolutely enjoyed every bit of it. I’ve got you book marked to check out new things you post…
I really liked your blog article.Really looking forward to read more. Much obliged.
accurately PS4 and Xbox vs. prefer, PS4 will have a
Major thanks for the blog.Really thank you! Great.
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Ö
how long does it take for lexapro to work how to wean off lexapro
augmentin pill clarithromycin ciprofloxacin convert
I really like and appreciate your blog article.Thanks Again. Awesome.
A round of applause for your post.Really thank you! Will read on…
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!
Thanks so much for the blog.Really looking forward to read more. Great.