DEV Community

Abel Terefe
Abel Terefe

Posted on

Working with Git terminal

What is Git? Git is a Supply Chain Management(SCM) that stands apart from the other SCM. Git has allows you to have multiple branches that are entirely different from each other. Every creation takes a few seconds and is completely easy to understand. In this article, I’ll be writing about some important keys, committing, pushing up to GitHub, and cool tricks. Also, this article is for mac users, but most of the keys should be similar to Linux or windows.
They are a lot of keys to use in the Git terminals. The cd (change directories, one of the most important keys is how you are able to change directories, which can be documents, folders, images, and etc. If you want to go back to the previous directory, then you insert the cd .. to go back. You can see all your list directories with the ls key. When it comes to making directories, you have to put mkdir. Seeing what directory you insert pwd. There are more keys out than there is chicken(lol maybe not that much), but you can search for them on the web.
You can commit, save, your repository on the local server. The reason to commit the repository on the terminal allows you to stage the repository, so you can push it up to a remote server. Let’s focus on how can we get the repository to be saved on the local server. To see what files have not been staged you would enter git status. Seeing what files that have not been staged in the repository is important because you may not want to commit some files you changed in the repository. After seeing the files that haven’t been staged, you would want to stage the files using the git add. It’s very important you type out the files name instead of using git add . because you may not want to commit some files. Last step, git commit that allows you to save the work to your local server. It’ll ask you to write a short message about why you are saving it. Doing this instead of hitting the save button will allow you to keep track of your previous commit that you can always go back.
Now that we staged our file, let’s learn about why we would want to push our work on GitHub. The reason to push it up to GitHub is that everyone all run into an accident that our computer may break on us, or accidentally spilling cereal on your laptop, which I have so don’t feel bad, or whatever reason your computer stops working. To push up on GitHub you would enter git push right after you git commit. Doing this allows your repository to be up on GitHub for you to have access to the repository on any computer because of it on the cloud, internet.
Let's go back to talking about commits, you can go back to the previous commit by entering git reflog which allows seeing all your previous commits to select the specific commit you are trying to get back to you would enter git reset HEAD@{index}. The index represents the specific commit number shown you trying to access. You can learn more on https://ohshitgit.com/ which has explicit language, so the clean version is on https://dangitgit.com/. These are websites with some pretty sweet git commands.

Top comments (0)