I first used git probably around 5 years ago, maybe sometime during the second or third year of my bachelor’s study. The problem is no matter how many times I use git, I still don’t understand it and end up forgetting many things. I admit, maybe I am not that smart.
So anyway, I am writing this article mainly for myself. Maybe if sometime in the future I forget how to use git again, then I can just look at this post and copy-paste everything (it’s not like I don’t do that already now).
So, let’s get started. I split this post into three parts as you can see in the following below:
- You already have a remote repository and want to clone it to your local
- You push changes from your local to your remote
Here we go.
How to clone a remote git repository to your local computer
So you already have a remote repository and want to clone it to your local computer. It’s probably the easiest one as it’s usually already stated on the git repository page itself.
You go to the page of your repository and find the ‘Code’ button. Then copy the HTTPS link like below.
Using the terminal in your computer, go to the directory you want to clone the repository to. Then run the following command in your terminal.
git clone https://github.com/catris25/myspotify-top100-2020.git
Wait for a few seconds/minutes depending on the size of the repository until it reaches 100%. Now your repository is ready to go.
How to push changes from your local to your remote
If you have cloned the repository to your local computer, have made some changes and now want to push those changes into the remote repository, then the commands you can use are the following.
But, first of all, which branch do you want to use? Do you want to use the default branch (master/main)? Or do you want to create a new branch (for example, dev)?
Check out all the available branches in your repository.
Create a new branch and switch to the newly created branch.
git checkout -b dev
Now that you have created a new branch and made some changes, you’re ready to go. Here’s how to push that changes (along with the new branch) to the remote.
git add . git commit -m "your commit message" git push origin dev
If you want more complicated git commands, then you probably need to look at other articles on the internet, because this is all that I know.
Thanks for reading!