Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

Most used basic Git commands in Programmer’s Life

Most used basic Git commands in Programmer’s Life

If you are programmer or coder then you know to importance of GIT in our live. Git is an important part of daily programming (especially if you’re working with a team) and is widely used in the software industry. In this post I am going to explain the most used Git commands.

Git Commands

Git Clone

Git clone is a command for downloading or cloning existing project’s source code from a remote repository (like Github,Gitlab…). In simple words, Git clone basically makes an identical copy of the latest version of a project in a repository and saves it to your computer.

git clone <https://name-of-the-repository-link>
for Example 
git clone  https://github.com/codentricks/Wordpress-Education-theme.git

Connecting to Github

git config --global user.email "email ID"
git config --global user. "username"
for example
git config --global user.email "[email protected]"
git config --global user.name "sonzoy"

Git Status

The git status command is used to display the state of the repository and staging area. Its provides all the necessary information about the current branch.

git status

Git Add

The git add command is used to add file contents to the Index (Staging Area). This command updates the current content of the working tree to the staging area.
To add single file

git add [FILENAME]
for example
git add style.css

To add multiple files

git add [FILENAME] [FILENAME] [FILENAME]
for example
git add style.css bootstrap.js bootstrap.min.css

To add all files and folder

git add *
or 
git add -A

Git Commit

This is maybe the most-used command of Git. Once we reach a certain point in development, we want to save our changes (maybe after a specific task or issue).
We also need to write a short message to explain what we have developed or changed in the source code. The git add command doesn’t change the repository and the changes are not saved until we use git commit.

git commit -a 
or with message in one command
git commit -m "Add bootstrap, jquery"

Git Push

After committing your changes, the next thing you want to do is send your changes to the remote server. Git push uploads your commits to the remote repository.

git push origin branch_name
for example
git push origin main
or 
git push -f origin main

Git pull

The git pull command is used to get updates from the remote repo. This command is a combination of git fetch and git merge which means that, when we use git pull, it gets the updates from remote repository (git fetch) and immediately applies the latest changes in your local (git merge).

git pull origin branchname
for example
git pull  origin main

If you getting merge error while push then try commands given below

# suppose branch name is  main
git config pull.rebase false
git checkout main
git merge main
git pull origin main
5 1 vote
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Do you have any Query / Suggestion