Basic git commands

Get git version:

git version

Set global user name:

git config --global user.name "Full Name"

Set global email:

git config --global user.email "[email protected]"

Clone a repository:

git clone https://github.com/your/repository.git

To get up to date from remote repo:

git pull

Check git status:

git status

To initialize:

git init

To stage edited files:

git add .

To commit the changes:

git commit -m “Changing summary”

To set a remote repository – SSH:

git remote add origin ssh://[email protected]:port/home/user/projects/myrepo.gitTo get the remote list:
git remote -v

To push:

git push origin

To check the log:

git log –oneline

To reset a specified commit:

git reset –hard <commit hash>

Update remote to a reset position:

git push -f origin HEAD^:master

To add an alias:

git config –global alias.sac ‘!git add –all && git commit -m’

To edit the global config:

git config –global –edit

To view all global config:

git config -l

Similar Posts