Remote Control Your Projects Using Git
Tags: github, git, webdev, programming
Published: 2021-03-08 16:49:42

#Has this happened to you?
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1dy7u4qz28xtqo1tttx3.png)
>You write a code yesterday that works properly and today you change the code and it doesn't work and you don't remember what code you wrote yesterday.

>So to deal with this problem, many developers and programmers use **Git version control**.

#What is git?
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3tci50zvsavfps1rlhrn.png)

**Git** is a software for tracking changes in any set of files, usually used for coordinating work among programmers, collaboratively developing source code doing software development.

#Getting Started 

To get started with Git, you need to download it to your machine. Head over to https://git-scm.com/ and download the version most compatible with your system.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g8r569n3ne3l35inkob3.png)

After installation, Open Command Terminal or git bash and write command ```git --version``` for checking that git is install perfectly or not.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1i5ewvkkkfrwsct9vvf.png)

#Setup Username and Email.
In Command Line, Write

For Saving Username  ```git config --global user.name "User Name"```  
For Saving Email id ```git config --global user.email "email"```



>Now it is time to learn how we can remote control our project using git.

In Command Line, Navigate to the Project Directory you want to control for that use standard cd command.

```cd directory name```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srjxsxpwwyiby5b9exw3.png)

#Initialize git.
Now the time has come to initialize git in our working directory.
for initialize git, use command

```git init```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uco34ob4etrysg01nrpp.png)


Now You Can Check Your Project Status.

Using Command
 ```git status``` 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0k7k0op6fppkul7i68ip.png)

Here you are seeing that after entering ```git status``` the message shows that all the files in the directory are untracked.
In my case, there is an ***index.js*** file in my directory.

#Adding

For Start Tracking the file use ```git add "file name"```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acpzxmappg9he2j6hl0t.png)

After Adding the file in Track You can check the status using
```git status```
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyi4tq5xx0xvnrldqa1j.png)

Here, You can see that the current status message is different from the previous status message and the color of file name is changed from red to green. This means that your file has been added for tracking.

#Committing the message.
Imagine that you work in a team where 3 or 4 people are working together in the same project. Now you add some functions to your project and forget to inform your teammates about your changes, Or you also forget which function you added last time. So you can use command for committing the changes. ```git commit -m "Message"```  

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlmrqmk75nybmmrj4d9d.png)


#Difference B/W Previous and Current Changes.
By using the git command we can see the difference between the previous changes from current changes.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5hcgcbft1hbmz9d5meh.png)

```git diff``` Using this command You can see the difference

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uynysu12vzq6yazbxdf6.png)

#History
We can check all commit history using 
```git log```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hijvtgjjmbim6234c79w.png)

Here, We can see all commit history with date and time.




>**Thank You for reading this blog 😀**
**I hope all of you have benefited after reading this blog 🎉**
>Here You Connect with me https://connect.rishavraj.codes/