GITHUB 101

  • Published
  • Posted in Hubspot
  • Updated
  • 4 mins read
  • Tagged as

Git is a version control tool widely used by developers, data scientists and data analysts. Git helps you to keep track of the modifications made to the project. Subsequently helping you to revert your projects to previous stages, review who made the last change and what modifications did they add, and who introduced an issue in the project and where. Hence this helps you better control the project. Git also helps you recover files by going to previous stages of your project.

Git also helps you synchronize with multiple people collaborating on the same project. Since all the collaborators have access to the most recent version of the project, this method ensures you are not mailing files to each other but rather directly making changes in the git project.

GitHub is a platform for hosting code for version control and collaboration. Developers use git to use GitHub. GitHub is a GUI for git.

Git Workflow

Workflow Elements

Working directory – It the directory on your local system where you are working.
Staging Area– In this, the files with the updated changes are marked to be committed to the local repository but not yet committed.
Local Directory – In this, the files with the updated changes are not yet stored in the local repository.
Remote Directory – Here, the changes you made to your file are safely stored in the local repository.

Workflow commands

Git add – This command is used to add files that are in the working directory to the staging area.
Git Commit – This command is used to add files that are in the staging area to the Local repository.
Git pull – This command is used to get files from the remote directory to your working directory.
Git fetch – This command is used to get files from the remote directory to the local directory.
Git merge – This command is used to get the files from the local repository into the working directory.

Step 0: Make a GitHub account.

Sign up for a GitHub if you don’t have one – GitHub

Step 1: Install git on your system.

Step 2: Introduce yourself to git.

Now once git is installed in your system you will have to tell git who you are so that git can identify you as the author.

$ git config --global user.name "YOUR_USERNAME"

or

$ git config --global user.email "YOUR_EMAIL"

Step 3: Create a new repository in GitHub.

You can create a new repository in your GitHub. Go to the following link to do  so – Create a New Repository (github.com)

Step 4: Start away with Git.

Now once you have created your repository on your GitHub, let’s access it using git.

Open your git bash and place your git terminal in the folder where you wish to work.

Let’s get started right away –

Initialize git:

Now initialize your project directory – $ git init

Add new changes:

Add all the new files to the staging area – $ git add .

If you want to add a particular file, then use – $ git add <filename>

Commit new changes:

Now commit your files to the local directory – $ git commit -m “your commit message”

Add remote origin and push:

Now you will have to mention in which repository you wish to add these new files/changes. So will use the following command – $ git remote add origin <your GitHub project url>

Once the remote origin is mentioned you now push the files to the repository – $ git push origin master

As an alternative, you can also use the following method to set up the remote repository on your system.

Now you can download your repository from the GitHub website in which you want to work, or you can clone the repository using the following command (using git terminal).

$ git clone <remote_repository_url>

Once done open your git command line and go inside your local working directory to further proceed with your project. 

Extra commands

There are a few commands that are often required.

Whenever the remote repository is updated on GitHub either by you or your teammates those changes are not reflected in the project folder in your local system. So, to inculcate those changes you can use the pull command.

$ git pull

Conclusion

The commands covered in this blog are enough for you to get started on GitHub. However, there are many advanced commands as well. You can research it as required by your project.

Happy collaborating !!!

Pragya Verma
Data Analyst
Addend Analytics

Addend Analytics is a Microsoft Gold Partner based in Mumbai, India, and a branch office in the U.S.

Addend has successfully implemented 100+ Microsoft Power BI and Business Central projects for 100+ clients across sectors like Financial Services, Banking, Insurance, Retail, Sales, Manufacturing, Real estate, Logistics, and Healthcare in countries like the US, Europe, Switzerland, and Australia.

Get a free consultation now by emailing us or contacting us.