Skip to content

8 Most useful Git commands for data scientists in 2021

    You’ve landed your first job as a data scientist after a long time of hard work and commitment. The period of orientation and familiarisation with the environment is now over. You will now be working on real-world projects.

    You’ve been given the duty of writing a function that performs a specific task in a project. Your role will be a part of a currently active project. You can’t merely write the code in your local office and send it to your colleagues via email. It must be incorporated into the project. Your function must be “merged” into the current codebase.

    You won’t be the only one who contributes to a project in most circumstances. Consider that each contributor is responsible for a little portion of the project’s writing. Combining the elements would be a difficult and time-consuming operation without a proper and efficient system. It would be impossible to maintain the process of integrating these little sections as the project grew larger.

    Thankfully, we have Git, which allows us to monitor all of the changes in a project in a very practical and seamless manner.

    A version control system is Git. It keeps track of all changes made to the code. The changes are saved in a database known as “repository,” or simply “repo.” We’ll go through 8 basic yet essential git commands in this tutorial.

    1. clone a git repository
    Git clone makes a duplicate of the project in your current working directory. All you have to do now is give the project a path. This path can be copied from the primary project directory on a hosting provider like GitLab or GitHu

    # clone with HTTPS git clone <a class="vglnk" href="*******">*******</a> # clone with SSH git clone*******

    2. git branch 2


    You only have the master branch if you clone the project to your own machine. All of the modifications should be made on a new branch, which can be created with the git branch command.

    git branch mybranch

    3.switch to git

    Creating a new branch does not imply that you are currently working on it. You must change to that branch.

    git switch mybranch

    4. Check the git status

    It gives a quick rundown of the present situation. You’ll be able to see the branch you’re working on. It also tells if you’ve made any modifications or if there’s anything you need to commit to.

    git status On branch mybranch nothing to commit, working tree clean

    5. add to git

    The branch you’r
    e working on diverges from the master branch when you make modifications to the code. Unless you do a series of activities, these modifications will not be seen in the master branch.
    The git add command is the first step. The changes are added to the staging area with this command.

    git add