Cheat sheet for work with Git


The cheat sheet on version control system - Git

to see commits

git log --pretty=oneline

to see remote URL repositories

git remote -v

to clone into a non-empty directory

git init
git remote add origin https://name\
git fetch
git checkout -t origin/master

an event log

git reflog

to change a repository

git remote set-url origin https://some\

a new repository

git remote add origin https://some\ 
git push -u origin master

to delete a branch locally

git branch -d fix-protobaz

to delete a branch on the server

git push --delete origin fix-protobaz

to remove a file from the index

git rm --cached --ignore-unmatch path/file.js

to create a new branch

git branch some_branch

to create a new branch and immediately switch to it

git checkout -b some_branch

to switch to another branch

git checkout some_branch

to edit last commit comment

git commit --amend -m "new comment"

discard last commit but save changes

git reset HEAD~

delete last commit and delete changes

git reset --hard HEAD~
blog comments powered by Disqus