Cheat Sheet Git
git
comandos
cheat sheet
Adicionar repositório e instalar pacote gh
apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
apt-add-repository https://cli.github.com/packages
apt-get update
apt-get install gh
Autenticar utilizando um token
echo "ghp_ToKeN" > ghtoken.txt
gh auth login --with-token < ghtoken.txt
Criar repositório publico/privado
gh repo create NOME_REPO --public
gh repo create NOME_REPO --private
Deletar repositório
gh repo delete NOME_REPO
Confirm: USER/NOME_REPO
Enviar arquivos para novo repositório
cd REPO
git init
git add .
git commit -m "first commit"
git remote add origin https://[TOKEN]@github.com/[username]/[repo].git
git push origin master
Atualizar repositório
git add .
git commit -m "second commit"
git push origin master
Autenticar utilizando a chave SSH (antes é necessário importar a chave public para dentro da conta no github)
ssh -T git@github.com
Migrar para outra Branch
rm -rf .git/
git init
git remote add origin https://[TOKEN]@github.com/[username]/[repo].git
git add *
git commit -am 'pilot commit'
git push -f origin master
Ver a Branch atual
git branch --show-current
# Ou:
git branch
Outros:
git init
git remote
git status
git add ../server.js
git commit -m "(feature/node): change app get send"
git push linuxtips main
git push origin main
git pull
git checkout main
git stash
git checkout 1-upload-project-linuxtips-punk-do-devops
git add .
git commit -m "Update readme.md removing breaklines"
git push -u origin 1-upload-project-linuxtips-punk-do-devops
git config --global user.name camilla-m
git config --global user.email "email"
git commit --allow-empty -m "Allow empty"
git log
git remote --help
git reset f04207 --hard
git blame README.md
git checkout -b new-branch