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@bitbucket.org/name/rep.git
git fetch
git checkout -t origin/master

an event log

git reflog

to change a repository

git remote set-url origin https://some@bitbucket.org/some/some_st.git

a new repository

git remote add origin https://some@bitbucket.org/some/test.git 
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~

cancel the merge (for example, if you don’t want to resolve conflicts)

git merge --abort

Comments

Popular posts from this blog

JavaScript Inheritance and Classes

Typical gulpfile.js

Swipe events on touch devices