Get Started with Git and GitHub

Chetas Shree Madhusudhan
4 min readFeb 20, 2022

Were you looking to get started with Git and GitHub? Do you need to collaborate with a team? Are you working on a project? What to contribute to an existing project?

And you have recently discovered that you need to know how to use git and GitHub? Then you are on the right page; this article will help you make your first to contribute to open-source projects.

This article will get you up and running with the basics. There’s a lot of stuff to learn if you want to use Git and GitHub like a pro; there are tons of youtube videos available for that. You can go way beyond this introductory information!

So Let’s get started!

Any time you see a command in this article that includes these marks: < > , you have to delete those marks and replace what’s between them with your own information.

Let’s say you see something like git add <filename>. That means that you would type, for example, git add get_started.md ,if you wanted to add a file named “get_started.md” to your GitHub repository.

First, you have to Install Git

It seems easy to install git on your computer. But it depends on your operating system as well. Luckily, for Windows users, just follow the given steps :

  1. Download git from the official website
  2. From Git Bash or your terminal of choice , run the following command.
git --version

3. Configure Git to your system

git config --global user.name "<Your Name>"
git config — global user.email "<your@example.com>"

Yoo, you have finally installed and configured git to your system

Now, let’s see the further process

  1. First, make a file on your desktop
  2. Now, open git bash, and run the command:
cd
cd Desktop
cd ‘<file you created on your desktop>’

3. Now let's initialize that file, run the command:

git init .

So, what does git init mean? Simply, this command will create a folder that contains several folders and files, like hooks, info, objects, refs, config, description, and HEAD in order to track our works. The logs of our changes will be recorded there.

4. Now, let’s clone a repo (u can clone an already existing repo by first forking that repo to your GitHub account or making a new repo ), run the command:

git clone “<the link of the repository you wish to clone>”

5. Always make a new branch, instead of working on the master branch, run the command:

git checkout -b “<your brach name>”

6. Make changes or add files accordingly

7. Now, open git bash in that file, and make sure that you are in the branch you have created and not in the master branch, in case you are in the master/main branch then run the 5th command again

8. Now, to check what changes you have done, run the command:

git status

all the red lines mean that those files have not been tracked and you have made changes it those or added them

9. You can push all the files or a specific file, run the command:

if you want to push just a single file :

git add <file name>

if you want to push all the changes and files :

git add .

10. It’s always a good practice to commit and write what changes you have done in short so that the other person can understand and it will be easy, run the command:

git commit -m “<add your commit message>”

11 . It is always good to see where you are going to push your code, run the command:

git remote -v

12 . Let’s push your code/changes !!!!

git push origin <your branch name>

Open the repository in your browser click on the green button

Click on Compare & pull request

Hurryy , you have finallyyyy done it !!! Congratulations, on your first contributions, and welcome to the world of open-source !!!!

Last but not the least, it’s about learning, exploring, and sharing. So keep contributing.

If you have decided to contribute, then do it right away. Don’t overthink or procrastinate. If you have any queries regarding this, feel free to reach out to me on LinkedIn or Twitter. And if this article helped you contribute in open source, do lemme know on LinkedIn, would love to know your first contribution. All the best !!! You can do it !!!

If you like this Medium or it helped you in any way, please like💓 and do comment if you have anything to add, it would help other contributors who want to contribute and get started :)

--

--

Chetas Shree Madhusudhan

I’m Chetas Shree, a Freshman pursuing Bachelors in Computer science and engineering. I am an enthusiastic and social person who loves to take up new challenges