Git Commands Every Data Scientist should know

Anil Kumar
2 min readMar 26, 2023

--

git — version

It shows the version of Git installed on your machine.

git init

It will initialize the project folder into a ‘git repository’

git status

In simple terms, it will show you exactly which files/folders have been modified.

git add .

It will add all your files to the git staging area. You can also add individual files to the staging area. For e.g git add ‘index.html’ .

git diff

It will show the difference between a file in the staging area and file that is present in the working tree(untracked file).

git commit -m ‘msg’

It will save your changes to your local repository. It’s good practice to include your proper commit msg which helps in debugging.

git push

It will push all the local changes that you have made to the remote github repository.

git pull

It will pull (fetch) all the updated code from the remote branch and merge it with your local branch.

git log

It will list down the entire commit history i.e all the commit that you have made till now.

git branch<name>

This command is used to create a new branch in your local git repository.

git branch

It will list down all the local branches that you’ve created.

git branch -a

It will list down all the branches i.e local branches + remote branches that’s available for checkout.

git branch -D <name>

It will forcefully delete the specified local branch (even if the changes are not committed).

git checkout <branch_name>

It is used to switch between local git branches.

git stash

It is used to temporarily remove the changes that you’ve made on the working. tree.

git remote

It will give the name of the remote repository for i.e “origin” or “upstream”.

git remote -v

It will give the name as well as the URL of the remote repository.

Hope this will be Usefull for You….!! Thanks

--

--

Anil Kumar

Data Scientist @iNeuron.ai Talk About DataScience, MachineLearning, AI