Git- sheet

 

git clone https://github.com/<my_username>/<fork>.git
git status
git log
git hist
q exit log/hist
git remote -v
git remote add upstream git://github.com/<user>/<repka>.git
git branch <branch_name>
git checkout <branch_name>
git add <file_name>
git commit -m "<comment>"
git push -f origin <branch_name>
gitk

Update fork
git fetch upstream
git checkout master
git rebase upstream/master
git checkout <branch_name>
git merge master
git push --set-upstream origin <branch_name>

Rollback pushed commit – it will dissapear from project’s history (dangerous)
Do it cautious if your project exist at least at two spaces (eg on server)…
git push -f origin <hash>:<branch>
git reset --hard <hash>


Remove all history from repo and push there current files (useful if you store binaries in a repo (bad boy!) and periodically want to make the repo smaller).. as usual, danger ololol kekekek:

git checkout --orphan new_branch create new branch without history

git add -A add there all (A) files

git commit -am "сommit message" commit

git branch -D master delete old ‘master’ branch

git branch -m master rename new branch to ‘master’

git push -f origin master force-push