Basic Git commands
- July 17, 2019
- Posted by: Ankush Thavali
- Category: Technology Blog
Git is an Open Source Distributed Version Control System. Git has a remote repository which is stored in a server and a local repository which is stored in the computer of each developer. This means that the code is not just stored in a central server, but the full copy of the code is present in all the developers’ computers.
The git init command can be used to initialize git repository used in project directory.
$ git init
The git clone command can be used to get a copy of an existing Git repository.
$ git clone [URI]
The git add command can be used in order to add files to the index. For example, the following command will add a file named blognow.txt present in the local directory to the index:
$ git add blognow.txt
To add all files to the index following command can be used.
$ git add *
The git commit command commits any files you’ve added with the git add command and also commits any files you’ve changed since then.
$ git commit -m “commit message”
The git push command send changes to the master branch of your remote repository.
$ git push origin master
The git status command displays the list of changed files along with the files that are yet to be added or committed.
$ git status
The git rm command deletes the file from your working directory and stages the deletion.
git rm blognow.txt