Skip to content

Instantly share code, notes, and snippets.

@aleixripoll
Last active March 3, 2017 10:27
Show Gist options
  • Save aleixripoll/65ba1a53ccb0d4e9974332fe1e4e7553 to your computer and use it in GitHub Desktop.
Save aleixripoll/65ba1a53ccb0d4e9974332fe1e4e7553 to your computer and use it in GitHub Desktop.
Git reference

LIST BRANCHES

REMOTE: git remote show origin
LOCAL: git branch

SET USERNAME

git config credential.https://github.com/<org>/repo.git.username <username>

MERGE/REBASE branch-1 => branch-2

git checkout <branch-2>
git pull
git merge/rebase <branch-1>

DELETE BRANCH

LOCAL: git branch -d <branch>
REMOTE: git push origin --delete <branch>

CHANGE REMOTE URL FROM HTTPS TO SSH

git remote set-url origin git@github.com:<org>/repo.git

GIT ROLLBACK

git log
git revert [1a890e7]

GIT ROLLBACK LOCAL CHANGES

git reset --hard
CHANGE COMMIT MESSAGE: git commit --amend

NEW BRANCH

git checkout -B <branch>

MOVE CHANGE TO A SINGLE FILE TO OTHER BRANCH

git checkout <otherbranch> myfile.txt

SET MELD AS MERGE/DIFF TOOL

git config --global diff.tool meld
git difftool -d <branch-1>..<branch-2>

git config --global merge.tool meld
git merge <branch>
git mergetool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment