In this tutorial you will learn about the use of some common git commands. this commands will help you in your daily works for programming of the projects. Git is widely used in the IT industry.
what is Git ?
it’s an Open Source Distributed Version Control System. It helps in tracking changes in source code, enabling different people to collaborate on different parts of the same project
working with local repository
Command: Git config
The git config command is used initially to configure the user.name and user.email.The Git config command is the first and necessary command used on the Git command line.
$ git config --global user.name "yourname"
$ git config --global user.email "firstname.lastname@example.org"
Command: Git init
Create an empty Git repository or reinitialize an existing one. A
.git folder is created in your directory. This folder contains Git records and configuration files.
$ git init Demo
Command: Git add
This command is used to add one or more files in the staging area. you can also use
. for add changed files at a time.
$ git add filename
$ git add .
Command: Git commit
This command is used to finalize your change and make it ready to push to the server. Remember that anything that is still upstaged — any files you have created or modified that you haven’t run git add on since you edited them — won’t go into this commit. They will stay as modified files on your disk. In this case, let’s say that the last time you ran git status, you saw that everything was staged, so you’re ready to commit your changes.
$ git commit -m "message about changes made"
Command: Git Status
This command is used to display the status of your working directory.
$ git status
Command: Git branch
git branch command is used to view list all the branches available in the repository. if you want the list of branch from remote just add
-r after this command and will return all branch available on remote.
$ git branch
Command: Git checkout
The git checkout command is used to switch branches if you work in another branch this command is used.
$ git checkout branch_name
Command: Git merge
The git merge command is used to merge one branch to another branch.
$ git merge branch_name
working with remote repository
Command: Git remote
Git remote command is used to connect your local repository to remote server. This command doesn’t provide real-time access to repositories.
$ git remote add origin <address>
Command: Git clone
This command is used to make a copy of a repository from an existing.
$ git clone URL
Command: Git pull
Pull command is used to receive data from the current active branch. It fetches and merges changes on the remote server to your working directory.
$ git pull URL
Command: Git push
The command git push is used to transfer the commits or pushing the content from the local repository to the remote repository.
$ git push -u origin master
So that’s it here is commonly used commands you have and we will add more commands that are used for git version controls for you
Or if you need any kind of support or help contact us by sending form contact form and our developer will connect with you to solve the problem