DEV Community

Cover image for Uso básico de git
Arthur Guimarães
Arthur Guimarães

Posted on • Edited on

1 1

Uso básico de git

Mais um post de git?

Quando eu estava aprendendo git, o mais comum era ter que pesquisar mais uma vez comandos que já havia utilizado, e com a diversidade deles acabava me perdendo ou me confundindo ainda mais.
Criei esse pequeno "esquema" para que eu pudesse consultar facilmente, coloquei todos os comandos que pessoalmente mais utilizo, e caso apareça algo novo eu simplesmente adiciono à minha lista. Sem ter que olhar trocentos comandos/sites até encontrar exatamente o que preciso.

Me ajudou bastante à decorar os comandos básicos e espero que possa ajudar alguém também. Aqui vão os comandos:

Criar uma branch

git checkout master
git pull
git checkout -b <nome_da_branch>
Enter fullscreen mode Exit fullscreen mode

Criar uma branch a partir da branch atual

git checkout master
git pull
git checkout <branch_que_já_existe>
git checkout -b <nome_nova_branch>
Enter fullscreen mode Exit fullscreen mode

Deletar uma branch local

git branch -d <nome_branch_local>
Enter fullscreen mode Exit fullscreen mode

Renomear uma branch local

git checkout <branch_que_sera_alterada>
git branch -m <novo_nome>
Enter fullscreen mode Exit fullscreen mode

Enviar uma branch local para o repositório remoto

git push origin <nome_branch_local>
Enter fullscreen mode Exit fullscreen mode

Deletar uma branch no repositório remoto

Para deletar uma branch remota, é preciso usar o comando "git push" com a opção "--delete":

git push origin --delete <nome_branch_remota>
Enter fullscreen mode Exit fullscreen mode

Merge na branch local a partir de master

git pull origin master
Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more