
Git is a source code management program that can be managed by Git commands as well as Git graphical user interface tools.
If you’re a developer, you might have to use Git today. We’ll talk about commands line tools in this article. What are Git Commands, and How Do we Use Them?
Table of Contents
List of git commands
What are Git commands? Following is the list of important git commands.
- git add
- git branch
- git checkout
- git clone
- git commit
- git config
- git diff
- git init
- git log
- git merge
- git pull
- git push
- git remote
- git reset
- git rm
- git show
- git stash
- git status
- git tag
Check git version
$ git --version git version 2.35.1.windows.2
SET Config Values
These variables are crucial since other developers need to know who is checking code in and out, making changes, and so on if you’re working with them.
As a result, this is how you may add your name to all of your check-ins and code modifications.
$ git config –global user.name “git-tutorial-525”
$ git config --global user.email "geekcer.code@gmail.com"
It’s critical to double-check that your user name and user email are both set. So, after you’ve gotten those values to work, you’re ready to go on.
Check the config values
$ git config --list
Establish a repository using existing code.
Users commonly begin using it in two situations: the first is when they have an existing project on their local system that they want to track with it, and the second is when they want to start generating whenever an existing project happens remotely.
Create a git repository from an existing directory.
$ git init
A URL may be used to retrieve a full repository from a remote repository.
git clone [url]
add command in Git
To add one or more files to the staging area, we use the add command.
git add [file]
git add *
commit command in Git
It saves (snapshots) a copy of the file in the version history and adds a message to it.
$ git commit -m "Message related to commit"
Any files you’ve added to the repository using git add, as well as any files you’ve edited since then, are committed with this command.
$ git commit -a
diff command in Git
This command displays differences in files that haven’t been staged yet.
git diff
This command displays the difference in files that are staged but not yet committed.
git diff --staged
status command in Git
This command displays the files that have been edited in the working directory and are ready for your next commit.
git status
push command in Git
To upload the contents of local repository content to a remote repository, we use the push command.
git push [alias] [branch] $ git push orgin master
All branches are pushed to the server repository with this command.
$ git push --all
pull command in Git
To get data from GitHub, use the pull command. It connects to the remote server and downloads and merges updates to your working directory.
$ git pull [link of repository]