Exploring Git

How is it different from centralised VCM?

A DVCM is secure as multiple users can push the code easily as they get copies of repos. If you lose backups, dealing with CVCM becomes a nightmare. Here lies the power of using Git.

Why Git?

  1. Git helps organizations share code among teams
  2. It improves your work and collaborate on projects
  3. Git helps you keep history through remote hosting services


To start from scratch, goto the directory where you want to work with your project in the terminal (Mac), and then start using Git commands given below as and when required.

  1. To initiate Git, the directory must contain .git in it. To create it,run command git init
  2. To find the status of your git files… like which files are staged and what are not tracked, run git status
  3. Next to keep stage your files, run git add <filename> to add a particular file or git add . to add all the files in that directory. You can add all the similar kind of files by git add '.*html'
  4. Now these added files can be committed by git commit, but this command directs you to VIM and give the commit a name in VIM.
  5. For ease in committing, use -m in git commit -m "My commit" to commit to master.
  6. To find logs run git log

For remote repos

  1. To access remote repos, firstly, clone the url from repos and start making changes to those files by running the following:
git clone https://github.com/hasura/git-push-template.git

2. To make changes live, push the code to the repo. -u in the following command, remembers what to push and where. You need not enter these details again and again

git remote add origin https://github.com/hasura/git-push-templates.gitgit push -u origin master

3. Pull requests let you tell others about changes you’ve pushed to a repository on GitHub. For pull request run git pull origin master or

git pull origin master --allow-unrelated-histories

4. To see changes in commits, i.e. from previous commit to the latest, run git diff HEAD.


If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it. A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master.

  1. Branching can be done by running git branch MyBranch
  2. git checkout MyBranch


Merging is used to merge the branches so that all the changes you made comes to live at once.

git merge -a -m 'changes made'

-a in the above is used to skip the staging step. However, any new files that are untracked must be manually staged using git add <filename>

Merge master into new branch

git merge master

This may arise an error saying CONFLICT. This can be resolved manually by going to the file and editing it. Fix this by deleting

<<<< HEAD
>>>> master

This can be fixed using tools like ‘tortisemerge’ tool or ‘winmerge’ tools. Firstly install these tools and then try running git mergetool

Learn more on https://try.github.io/ and http://gitreal.codeschool.com/

In Short:

cd repository
git branch new-branch
git checkout new-branch
git checkout master
git add -A
#push to new branch
git push --set-upstream origin new-branch
git remote -v
git remote add upstream https://github.com/TejasReddy9/sec_bichromaticds.git
git remote -v
git fetch upstream
git checkout master
git merge upstream/master


Hasura local development setup



Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store