Only a easy information for getting began with git. no deep shit.
Create a brand new repository

Let’s run following git commands to get began with git listing:
# let's create a brand new git undertaking
$ mkdir my-project
# let's initialize git
$ cd my-project
$ git init
Checkout a repository
Now create a working copy of an area repository by operating the command.
git clone /path/to/repository
When utilizing a remote server, your command will be-
git clone [email protected]:/path/to/repository
Git workflow
Your native repository consists of three “timber” maintained by git. the primary one is your Working
Listing
which holds the precise information. the second is the Index
which acts as a staging space and at last the HEAD
which factors to the final commit you’ve got made.

Git add & commit
You may suggest adjustments (add it to the Index) utilizing
git add <filename>
git add .
This is step one within the primary git workflow. To truly commit these adjustments use
git commit -m "Commit message"
Now the file is dedicated to the HEAD, however not in your distant repository but.
Pushing adjustments
Your adjustments at the moment are within the HEAD of your native working copy. To ship these adjustments to your distant repository, execute
git push origin grasp
Change grasp to no matter department you wish to push your adjustments to.
When you have not cloned an current repository and wish to join your repository to a distant server, it’s worthwhile to add it with
git distant add origin <server>/url
Now you’ll be able to push your adjustments to the chosen distant server .
Git branching
Branches are used to develop options remoted from one another. The grasp department is the “default” department while you create a repository. Use different branches for improvement and merge them again to the grasp department upon completion.

Create a brand new department named “feature_x” and swap to it utilizing
git checkout -b feature_x
swap again to grasp
git checkout grasp
and delete the department once more
git department -d feature_x
A department is not obtainable to others except you push the department to your distant repository
git push origin <department>
Git replace & merge
To replace your native repository to the latest commit, execute
git pull
In your working listing to fetch and merge distant adjustments to merge one other department into your lively department (e.g. grasp), use
git merge <department>
In each circumstances git tries to auto-merge adjustments. Sadly, this isn’t at all times attainable and leads to conflicts. You’re accountable to merge these conflicts manually by modifying the information proven by git. After altering, it’s worthwhile to mark them as merged with
git add <filename>
Earlier than merging adjustments, you too can preview them through the use of
git diff <source_branch> <target_branch>
Git tagging
It is beneficial to create tags for software program releases. this can be a recognized idea, which additionally exists in SVN. You may create a brand new tag named 1.0.0 by executing
git tag 1.0.Zero 1b2e1d63ff
The 1b2e1d63ff stands for the primary 10 characters of the commit id you wish to reference together with your tag.
Git log
In its easiest kind, you’ll be able to research repository historical past utilizing.. git log
You may add a variety of parameters to make the log appear to be what you need. To see solely the commits of a sure writer:
git log --author=rob
To see a really compressed log the place every commit is one line:
git log --pretty=oneline
See solely which information have modified:
git log --name-status
Change native adjustments
In case you probably did one thing improper, which for certain by no means occurs ;), you’ll be able to substitute native adjustments utilizing the command
git checkout -- <filename>
This replaces the adjustments in your working tree with the final content material in HEAD. Modifications already added to the index, in addition to new information, can be stored.
When you as a substitute wish to drop all of your native adjustments and commits, fetch the most recent historical past from the server and level your native grasp department at it like this
git fetch origin
git reset --hard origin/grasp
Conclusion: As trendy internet builders, we’re seemingly to make use of git each day. It is a fantastic distributed model management system. You should also read more about git merge issue here.