STARTING WITH GIT

Samarjit Mahi
3 min readMay 5, 2020

--

if you want to track your project then how can you do it?

to solve this problem there comes GIT for you. it is a version control system that tracks all changes to your files and directories efficiently.

To understand it more. let imagine you have a document with version 1, you make changes to it now you have version2 and you do more changes and now you have version3. GIT will keep track of all three versions for you.you can also check back and forth between versions of your project and compare to see what changes you have done.so it called VERSION CONTROL SYSTEM.

GIT HISTORY

git was born in April 2005 .it is created by Linus Torvalds.as the year passes more and more users are using Git. than GitHub launch in 2008 to host git repositories. in 2018 git is purchased by Microsoft.i 2019 over 57 million repositories are created and 28 million users are using.

it all possible due to the following characteristics of git:

1.open-source and free software

2.compatible with Linux, Windows,macOS

3.better safeguard against data corruption

installation and initialization of your project :

go to this link and install git according to your operating system.

https://git-scm.com

to check whether the git is installed use the following command

after installation, the next step is to initialize a repository or git in your project. I am using the command prompt for the initialize git. make sure you are inside your project. the first command is git init which initialize your project to git .to check for git files type ls -la than u will see some dotfiles inside your project which is responsible for tracking your files.now add some files inside your project .than type git status which tells u about all untracked files in red color.to add all your files to git type git add . it will add all changes that are in the current directory.that for committing type git commit -m “comment…….” .now you can track your project forever.

git initialization

sum up :

— first make changes you want

— add the changes to git

— commit changes to the repository with message

to view, all the commits use git log.it will return all the logs of your project.

tree architecture

there are other commands also git diff used to find all changes to your files.to permanently delete any file use git rm <filename>.it will remove your file from the working area.to move and rename your file use git mv <file name> <rename filename>

git commit -am “your comment” it will commit and staging both in single code.

git diff — color — words will tell which exact words are changes.

importance of .gitgnore file in your project

if we don’t want to track the files and changes or if there is a temporary file that you do not care about then use gitignore file.changes made to ignore files will be ignored by GIT.

for eg: logs/*.txt — all files inside log will directly ignore by git if u put this inside.gitignore file

so far we have covered all the commands that are essentials to working with git.now putting your project into GitHub. GitHub is a platform where you host your git files.

first, create a new repository

git remote add origin http://________________.git

git push -u origin master

now your files are on github.after that if you update any files than typed git push .it will directly make changes to your GitHub project.

--

--

Samarjit Mahi

pursuing bsc computer science from PGDAV College(DU) tech enthusiast|community lover|dancer|wannapreneur| hosting my podcast-The Samar Audio Experience