Table of contents
No headings in the article.
Git is a powerful version control system that allows developers to track changes in their code and collaborate on software projects. In this article, we will explain some of the basic Git commands and provide examples of how to use them.
git init: This command is used to initialize a new Git repository.
For example, to create a new repository in the current directory, you would use the following command:
rachana-uniyal@rachanauniyal:~$ git init
git clone: This command is used to create a local copy of a remote repository.
For example, to clone a repository named "myproject" from the user "username", you would use the following command:
rachana-uniyal@rachanauniyal:~$ git clone https://github.com/username/myproject.git
git config: This command is used to set configuration options for a Git repository.
For example, to set the user's email address for the current repository, you would use the following command:
rachana-uniyal@rachanauniyal:~$ git config user.email "youremail@example.com"
git add: This command is used to stage changes for a commit.
For example, to stage all changes in the current directory, you would use the following command:
rachana-uniyal@rachanauniyal:~$ git add .
git commit -m: This command is used to save changes made to the repository. The "-m" option is used to provide a commit message.
For example, to commit changes with the message "added a new feature", you would use the following command:
rachana-uniyal@rachanauniyal:~$ git commit -m "added new feature"
git status: This command is used to view the status of the local repository, including the changes that have been made but not yet committed.
For example, to see the status of the "myproject" repository, you would use the following command:
rachana-uniyal@rachanauniyal:~$ git status
- git log: This command is used to view the commit history of a repository. For example, to see the commit history of the "myproject" repository, you would use the following command:
rachana-uniyal@rachanauniyal:~$ git log
git diff: This command is used to view the differences between two commits or between the working tree and the index.
For example, to see the differences between the latest commit and the previous commit, you would use the following command:
rachana-uniyal@rachanauniyal:~$ git diff HEAD~1
These are some of the basic Git commands that can be used to manage and collaborate on software projects. There are many other commands and options available, and it is best to consult the official Git documentation for more information.