Thursday, 17 June 2021

Git Commands: used by a developer on daily basis

How to initialize a project or any folder to use the git?

Typically, developers use the git for better continuous integration (collaborative work among multiple team members). But, in general, any person who is novice to the computer knowledge can take the benefit of the git version control system. For example, a novel writer, can use the git.

git init

<in a project folder> will initialize the git & git for then, tracks your changes.


How to check the current status of git? 

git status

This command helps the user of the git to know what is the current status of the version control: like what files are changed, among those files which are being in untracked & in staging (ready to commit state).


How to check the logs of git?

git log 

git log --oneline

The above commands help you to show the recent commits to current project. Note: Every commit will have a SHA id(an alphanumeric id) & author info. Generally, we use to know what's the recent changes that have been added to a file / project. 


How to check the branch info?

Branching model in git is a model, where individual work piece assigned to a developer is developed on a different branch, sometimes called as feature branch. Generally, we name the branches with the work related terms. For example, if I am working on purchase order related work, I will create a new branch with a suitable name something like purchase-order branch or sometimes we create branches with JIRA story numbers (for example, on DCP project - branch : DCP-1234)

To the know what are the branches existing: we can use 

git branch

this command will show all the branches. Some branches will be both remote & local branches. This means, during the initial development of a piece of work, the branch may still exist as a local branch for that developer. Until this branch is been pushed, it will have only a local branch. Once a branch is pushed & it will be available in remote.

How to see the local & remote branches using terminal?

To see all the local & remote branches:

git branch -a 

To see the local branches:

git branch

To see the remote branches:

git branch -r


No comments:

Post a Comment