DEV Community

Cover image for Remote Control Your Projects Using Git
Rishav Raj
Rishav Raj

Posted on

Remote Control Your Projects Using Git

Has this happened to you?

Alt Text

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

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

After installation, Open Command Terminal or git bash and write command

git --version

for checking that git is install perfectly or not.
Alt Text

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

Initialize git.

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

git init

Alt Text

Now You Can Check Your Project Status.

Using Command

git status

Alt Text

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

After Adding the file in Track You can check the status using

git status

Alt Text

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

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

git diff

Using this command You can see the difference

Alt Text

History

We can check all commit history using

git log

Alt Text

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/

Top comments (0)