Getting Started With Git? A Complete Git Beginner.
Tags: git, howto, windows, beginners
Published: 2023-03-15 09:16:29

---
title: Getting Started With Git? A Complete Git Beginner.
published: true
description: Before using git, I though git is super complicated. But my peer just gave me some simple commands for daily use.
tags: git, howto, windows, beginner
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-02-26 08:32 +0000
---

I try to recall my first time using git. I was not a tech-guy back then, not even close. Pencil, Pen, and Photoshop was my daily tools back then. 

Later I jumped into web development. When my peer told me about collaboration using git, it overwhelmed me with command-line-stuff. I thought it was a really complicated stuff. But my peer just gave me some simple commands for daily use. And I only use those some-simple lines until now, except sometimes-unexpected things happened.

I am writing these down, since I had to share how to use git to my class. And I just gonna __skip__ the complicated parts. Hope it helps

### Install Git, If It's Not Installed Yet

![Site to Download Git](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/33zwa9kth7xu7nt8ynzc.png)

Download the installer from https://git-scm.com/download/win, ran the installer, and if you don't understand anything the provided options presented, just go with the default.

### Using Git

![Terminal in VSCode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kglfu8hocxjrs73q4y2n.png)

Git commands can be directly used from VSCode terminal, you can open the terminal by pressing __Ctrl__ + __Shift__ + __`__. Or you can open it from the top menu __Terminal__, then choose __New Terminal__.

### If It Is An Existing Repository
#### 1. Clone The Repo

![Github Repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9rf2lixpmz7f0r20hvwv.png)

If-it is an existing Repository, go to the repository on Github, click the __"Code"__ button, and copy the git url (you can just click the right side button). then go back to the terminal and type __git clone__ command like this. (using the developer-roadmap repo as example)

```
git clone https://github.com/kamranahmedse/developer-roadmap.git
```

#### 2. Config - One time only
This command actually write the config file inside the hidden .git folder. We'll skip it, just remember that you can always re-config using this command.

```
git config user.email "tapas@someemail.com"
git config user.name "Irwan Phan"
```

#### 3. Add and Commit Changes
To add the files changed to staging, we use the __git add__ command follow by file name or directory/folder name. But we can also just add all the changed files by using . like below.

```
git add .
```

The next thing to do after added the changes to staging area is to commit it using __git commit__ command, and remember to always makes the commit title as clear as possible.

```
git commit -m "change the x part with x2y"
```

#### 4. Push To Repo (Remote Repository)
Push the committed changes to the remote repo by using __git push__ command follow by __remote__ and branch name, e.g __main__. If it's a cloned repository, you'll only need to type __git push__.

```
git push
```

### If It Is A New Repository
#### 1. Initiate A Repo
To create a new repository, we can use the __git init__ command followed by repository name, or just __git init__.

```
git init repo-name
```

#### 2. Config
Use __git config__ for user name and email used in your Github like mentioned in step #2 above.

```
git config user.email "tapas@someemail.com"
git config user.name "Irwan Phan"
```

#### 3. Add And Commit Changes
Use __git add__ to add to staging and __git commit__ to commit the changes.

```
git add .
git commit -m "change the x part with x2y"
```

#### 4. Push To Repo (Remote Repository)
To push to a new remote repository use __git push_ command followed by __-u__, __remote__, and branch name.

```
git push -u remote main
```

### Wrapped
I hope this note could be of help for anyone. I tried to make it as simple as possible. For more information on how to use git, you can visit here https://training.github.com/downloads/github-git-cheat-sheet/.