You can easily find GUI to accomplish following operations these days but here are some of the most commonly used Git commands, along with brief explanations and examples:
git init
: This command initializes a new Git repository in the current directory. It creates a new.git
directory that stores all the information required to track changes in the repository.
Example: $ git init
git clone
: This command creates a local copy of a remote Git repository. The repository can be on a remote server or on a local network.
Example: $ git clone https://github.com/user/repo.git
git add
: This command adds a file or group of files to the staging area, which is where changes are tracked before being committed to the repository.
Example: $ git add file1.txt file2.txt
git commit
: This command records changes to the repository. When you rungit commit
, you must also provide a message that describes the changes you're committing.
Example: $ git commit -m "Fixed a bug in the code"
git status
: This command shows the status of the repository, including any changes that have not yet been staged or committed.
Example: $ git status
git diff
: This command shows the differences between the current version of the code and the latest commit.
Example: $ git diff
git log
: This command shows a history of all the commits made to the repository.
Example: $ git log
git checkout
: This command allows you to switch between different branches or to a specific commit.
Example: $ git checkout master
git branch
: This command allows you to create, list, or delete branches.
Example: $ git branch new-feature
git merge
: This command combines the changes from one branch into another branch.
Example: $ git merge new-feature
These are some of the most commonly used Git commands, but there are many more available to help you manage your Git repositories.