How to Use git on centos 7

Use git on centos 7

How to push all changes in gitlab, GitHub, bitbucket using git command line

git add .

Commit changes with messages so that changes can be identified easily

git commit -m "Add existing file"

Now finally push code to the mentioned repository (origin- https://repository url ) and followed by branch

git push origin your-branch

How to add new remote, How to add new repository url

Example – By Default, we have “origin” with a particular URL.
the requirement comes to add code to the different repository as well

Check your existing remotes

git remote

Check remote with its defined url

git remote -v

Add new git remote “techouse

git remote add techouse https://[email protected]/magento/zafco.git

Fetching real stuff(.git config) from new remote

git fetch pb

Now pull or push your as per your requirement

git pull pb master

How to Inspecting a Remote

git remote show origin

How to rename remoting

git remote rename pb paul
git remote

How to delete existing remote

git remote remove paul


git remote rm paul
git remote

How to replace username or email

git config --global --replace-all "New User Name"

How to clone in git

git clone /path/to/repository
git clone username@host:/path/to/repository

how to git push

git push origin master
git remote add origin paste_url

How to create branch

git checkout -b feature_x
git push origin <branch>

how to switch branch

git checkout branch_name

How to delete branch

git branch -d feature_x

How to pull

git pull origin master

How to git merge and fetch

git merge <branch>


git merge from_branch to_branch
git fetch branch

How to know difference

git diff <source_branch> <target_branch>

How to use tagging (version control)

git tag 1.0.0 1b2e1d63ff

How to see git logs

git log
git log --author=bob
git log --name-status

How to replace the local changes

git checkout -- <filename>

How to drop call changes

git reset --hard origin/master

How to config global user

git config --global --unset-all
git config --global --add <whatever>

How to remove file from git

git rm file1.txt
git commit -m "remove file1.txt"
git rm --cached file1.txt
git push origin branch_name

How to remove the branch from the local git?

git branch -d branch_name

How to remove the branch from the remote git repository?

Example:- you want to remove the development branch from your git repository then run this command accordingly.

git push –delete remote_name branch_name

Example :- git push –delete development.git


I provide help to beautiful people like you. I love hanging out with my dog

You may also like...

2 Responses

  1. john says:

    great article , all useful commands thank you so much .

  2. Risha says:

    Very helpful

Leave a Reply

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

× How can I help you?