Let’s work with Git

[fusion_text]Git is a widely used version control system for software development.

It is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows.

A simple guide to use: Some of the basic commands Create a new repository Create a directory, open it and run the command gitinit

Checkout a repository Create a working copy of local repository running git clone/path/to/repository

For remote host git clone username@host:/path/to/repository

Workflow structure The local directory maintain a tree based structure in git, where root is the Working directory , holding actual files.

The second one is the Index which acts as a staging area and finally the HEAD which points to the last commit you’ve made.

Add and Commit The propose changes you can add by using git add , this is the first step of git overflow

To actually commit the changes made use git commit -m “Commit message” , now the file is committed to the HEAD

 

Pushing changes to the remote To send the changes in HEAD to your remote repository, execute git push origin master

The master branch is the default branch when you create a repository.

Branching To create a new branch named “feature_1” run git checkout -b feature_1

To switch back to master git checkout master

Delete the branch created git branch -d feature_1

Push the new branch git push origin

Update and Merge Update your local repository by git pull/path/to/repository

To merge branch into the master branch git merge

Tagging We know the advantage to create tags for software releases. You can create a new tag named 1.0.0 by executing

git tag 1.0.0 1x2e1e63cc

1x2e1e63cc stands for the first 10 characters of the commit id you want to reference with your tag.

Distributed version control system is very useful when developers stay in different places and work in same development project. Git is one of the widely used reliable systems in this case.  Using git, developers used to keep all versions of projects on a central server, and individual developer checkout and upload changes back to this server.[/fusion_text]

Leave a Reply

Your email address will not be published. Required fields are marked *