Member-only story

Git basic and important commands…

Praveen David Mathew
4 min readNov 15, 2020

Creating Git local repository and connecting with remote repository:

Git init
Git remote add origin <url>
Git config --global user.email <anyemail>.com
Git config --global user.name <anyname>
Git push --set-upstream origin master

Cloning a repository:

git clone <repository_git_url>

Creating new remote branch:

git checkout -b <branch_name> 
git push origin <branch_name>

Delete a remote branch:

git push origin :<branch_name>

Delete a local Branch:

git branch -d branch_name
git branch -D branch_name

Note: -D deletes the branch even if the branch is not pushed yet ( its similar to — delete — force)

How to change the remote URL:

here origin is the alias name for this remote repo. You can give any alias name.
now onwards u can refer a remote branch as alias/branch eg origin/mybranch

git remote set-url origin <url>

How to reset local changes:

this will reset local changes to master branch content, u can specify any remote branch . origin is the remote you set using previous command

--

--

Praveen David Mathew
Praveen David Mathew

Written by Praveen David Mathew

An open source advocator/WebdriverIO Projectcommiter/Postman Supernova/Postman-html-extra contributor/Stack overflow sqa moderator/Speaker

No responses yet