GIT is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primary used for source code management in software development, but it can be used to keep track of changes in any set of files. As a distributed revision control system, it is aimed to speed, data integrity, and support to distributed, non-linear workflows.
Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development. Its current maintainer since 2005 is Junio Hamano.
Enough, we the introduction. Let’s go to this 10 commands.
1. GIT Config
The git config command is used to setup your username and email in the main configuration file.
Checking the current Username
Type: git config –global user.name
Checking the current Email Address
Type: git config –global user.email
Setting up your Username
Type: git config –global user.name = “louierosero-gss”
Setting up your Email Address
Type: git config –global user.name = “firstname.lastname@example.org”
2. GIT INIT
The git init command is used to initialise a git repository for a new or existing project.
To make your selected folder to be the root of your project directory.
Type: git init
3. GIT Clone
The git clone command is used to make a working copy of an existing git repository from remote source.
Where going to clone a Git Source Code
Type: git clone https://github.com/git/git.git
4. GIT Status
The git status command is used to check the status of files you’ve changed in your working directory.
Type: git status *// do this is see what is the changes you make in your working *directory.
5. GIT Add
The git add command is used to adds changes to stage/index in your working directory.
Type: git add index.html // Do this when you want to add the specific file in your directory.
Type: git add . // Period means, you are going to add all the changes you make in your working directory.
6. GIT Commit
The git commit is used to commits your changes for your remote repository.
Type: git commit -m “Initial Commit” // Do this if this is your first commit.
Type: git commit -m “Additional Changes” -m “Modified Changes” // Do this if you want to have a multiple commits.
7. GIT Pull / GIT Push
The git pull command is used to get the update version of the existing files that you are currently working with. While the git push command is used to push your latest changes in your working remote repository.
Type: git pull <:remote:><:branch:> // git pull origin master, if you are only working in your Master Branch.
Type: git push <:remote:><:branch:> // git push origin master, if you are only working in your Master Branch.
8. GIT Branch
The git branch command is used to list out all the existing branches. Including the Master branch.
Type: git branch or git branch -a // to list all the remote branches.
9. GIT Checkout
The git checkout is used to switch to different branches.
Type: git checkout development // In here you switch from Master branch to Development branch.
Type: git checkout -b modification // Do this if you want to create and switch to a new branch.
10. GIT Merge
The git merge command is used to merge the two branches you were working on.
Type: git merge <:branch_you_want_to_merge:> // Let say, you want to merge the Master Brand and Development Branch. First thing you do is make your current branch to be a Master Branch then git merge it with Development Branch.
*This is the list of commands that I feel are essential and get things done, when learning the used of GIT. There is still a lot of command to be explore. So, I suggest you to this GIT Tutorial by Atlassian to learned more about GIT. *
Also check-out the following blogs.
Skills you need to learn for your first front-end jobs.
Make your website interactive using Velocity.js