The most used Git commands

The most used Git commands

Official documentation

git checkout -b {BRANCHNAME} origin/{BRANCHNAME} - Check out a branch from a remote repository, {BRANCHNAME} branch name

git log --pretty=oneline - Will display a single line description of the commit

Rollback the commit

The case when you already have a clone of the repository with which you work, you do a pull and you see that there is some bullshit committed by the developers.
We select the required branch, in mine it is called master 
git checkout master 
we roll back the changes in the repository for the example to two commits ago 
git reset --hard HEAD~2 

It is possible to make a certain commit by hash 
git reset --hard HEAD hash 
The hash can be obtained from the github web interface.

Next, we make a forced commit to the main repo on Github 
git push -f origin master without -f will swear that your version is younger than the one in Github and you need to do before pull

We change the link on Origin

git remote set-url origin {NEWURL} 
check the changes 
git remote -v

Push the branch to the remote repository and track

git push --set-upstream origin BRANCHNAME