GIT command Helper/Cheatsheet
Successful Git Connection
ssh -Tvvv git@github.comCopy Shh key from Macbook
pbcopy < ~/.ssh/id_rsa.pub
Generate SSH Key Github
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa (regular unix system)
$ ssh-add -K ~/.ssh/id_rsa (for macbook)
$ pbcopy < ~/.ssh/id_rsa.pub (for macbook)
Paste key into github
$ git remote add origin git@github.com:xxxxxx/xxxxxxx.git
$ git remote -v
$ git push -u origin masterSETUP REMOTE GIT
git init git add . git status git commit -m "First commit" git remote add origin git@github.com:xxxxxx/xxxxxxx.git git remote -v git push -u origin master
Add Key to github
cat ~/.ssh/authorized_keys cat ~/.ssh/known_hosts
SYNC GIT
git remote updategit fetch Downloads the latest from remote without trying to merge or rebase anything.
git fetch -- allREMOVE untracked files
git clean -f -dRESET BRANCH/FILE
git reset --hard origin/master -- force discard local changesgit reset --hard origin/<davidBranch_name> -- force discard local changesgit checkout -f <localfile> -- force discard local changesCOMMIT
git commit -m ‘My commit David Raleche’Amend a COMMIT
git commit --amend
remove git add
git reset HEAD -file-PUSH
git push origin <davidBranch>CONFLICTED FILES
git diff --name-only --diff-filter=UGIT ADDgit add <file>git commit -m “message of your commit” git push origin
GIT RESET ADD
git reset <file>git reset
(VERY DANGEROUS) REMOVING LAST COMMIT (VERY DANGEROUS)
git reset --soft HEAD~1git reset --hard HEAD^(VERY DANGEROUS)
GIT CHECKOUT SOMEONE ELSE REPO
git checkout --track origin/ECOM-307Git Diff
git diff –name-only –diff-filter=UGit log HELPER
git log –graphgit log –oneline
Comments