Skip to content

Latest commit

 

History

History
67 lines (36 loc) · 1.34 KB

git.md

File metadata and controls

67 lines (36 loc) · 1.34 KB

Git Cheat Sheet 💩

Tend to forget simple commands that I don't use so much and for improved productivity decided to write them down.

Resolving Conflict

To make life easier for oneself, have different branches on different computers -- makes resolving easier, maybe.

Merge Conflict

On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commits each, respectively.

See where you diverged:

git reflog

More visual one-liner:

git log --graph --decorate --oneline $(git rev-list -g --all)

To Revert

git revert SHA from git log --graph --decorate --oneline

To Reset

Soft

This will keep the reference logs:

git reset --soft HEAD@{n}

n is from reflog

Hard

Hard reset will discard the reference logs.

git reset --hard HEAD@{n}

Rename repository

  1. Rename on Remote host, e.g. https://github.com/akerge/cheat-sheets

  2. Rename directory on local host

  3. Set new URL using git

git remote set-url origin [email protected]:akerge/cheat-sheets.git

Choose Your Own Adventure

To have an adventure, follow this

Branching

I see that you didn't bother to RTFM. Anyways,

git branch -a lists all, -remote and local branches

-d deletes a branch

-b creates a new branch and checks out, 2-in-1