I’m one of those people who’ve struggled understanding Github terminal commands. Now that I finally understand some of it, I’d like to share this here on my blog. This post will cover the basics that you need to know to get started and use GH comfortably 🙂
The instructions to install git and everything around it can be found on the official git website
https://git-scm.com/ . Just download the installer and install git on your computer.
Creating a repository on GitHub
This is pretty simple and intuitive. You need to have a GH account. Create on on
github.com and then just
create a new repository. You can follow their documentation if needed.
Pushing your files to GitHub
Let’s say you create a new repo which says
coolest-addon and you have this coolest add-on ready in a folder on your desktop. You can then push it to GitHub by following this guide or by following the instructions below!
- Open the terminal and switch to your
coolest-addonfolder by using the
cdcommand. I’d do something like
- Next use
- Add all files using
git add .
- They’re now ready to be commited.
git commit -m "First commit"
- Add URL for remote repo
git remote add origin <remoteRepositoryURL>(without the angle brackets)
- And finally push using
git push -u origin master
git checkoutto see if your branch is up to date
git branchto see all branches and also to see the active one
git checkout <branch-name>to switch to a branch
git checkout -b <branch-name>to create a new branch and check it out
git push -u origin <branch-name>to push your new branch
git pullto pull changes to your branch
People working on the same project can check your new branch using these two commands:
git checkout origin/your_branch
I personally learn things by practice, by actually doing them. Starting with Github is tough for most people because we’re scared that we’ll break something or that we’ll make a mistake which’ll be a public embarassment for us. Something that’ll be documented online.
To overcome this fear, you can experiment in a repo called Spoon Knife. The repo is made for beginners to test things out. So feel free to perform experiments there 😀
- Specifically, when you visit that repo,
forkit to your repositories.
- Go through the readme file and make changes in it.
- Create branches, pull requests, merge those PRs, delete branches.
- Do everything you can till you get it.
That’s all in this post! 🙂