Skip to content

Instantly share code, notes, and snippets.

@AlexGalhardo
Created May 6, 2022 18:35
Show Gist options
  • Save AlexGalhardo/c07a8a994a342c9973812b10a38ffdbe to your computer and use it in GitHub Desktop.
Save AlexGalhardo/c07a8a994a342c9973812b10a38ffdbe to your computer and use it in GitHub Desktop.

Install Git

  • sudo apt install -y git

Edit Password

Iniciar git dentro do repositório

  • git init

Adicionar arquivo para o stage

  • echo "Hello He4rt Devs" > index.html
  • git add ola.txt

Adicionar todos os arquivos para o stage

  • git add .

Fazer commit com comentário

  • git commit -m 'comentario_here'

Criar Branch development

  • git checkout -b development
  • git branch

Merge branch development to master

  • git checkout master
  • git merge development

Adicionar local remoto

  • git remote add github url_github_here

Push branch master para local remoto

  • git push github master

Pegar arquivos(pull) da branch master do local remoto

  • git pull github master

Ver todos os logs dos commits

  • git log

Ver todas as alteraões feitas em cada commit

  • git show

Push outra branch para local remoto

  • git push github dev

Ver alterações feitas antes do git add

  • git diff

Deletar .git local

  • rm -rf .git

Apagar Diretório Remoto

  • git remote rm diretorio

Apagar arquivo ola.txt do git stage

  • git rm ola.txt -f

Apagar todos os arquivos dentro de um diretório forçado e de forma recursiva

  • git rm nome_pasta/. -fr

Apagar branch locamente

  • git branch -D

Apagar branch remoto

  • git push --delete

Evitar de algum arquivo não ser visto pelo git

  • criar arquivo chamado ".gitignore" (adicionar arquivos que não serão vistos pelo git dentro deste arquivo)

GIT Fetch All Branchs

GIT Pull All Branchs

  • git pull --all

GIT Push All Branchs To All Remotes

Revert to GIT Hash

  • git revert a867b4af..0766c053

GIT Clear History

  • rm -rf .git
  • git init
  • git add .
  • git commit -m "Initial commit"
  • git remote add origin git@github.com:/.git
  • git push -u --force origin master

Uninstall GIT

  • apt-get remove git
  • apt-get remove --auto-remove git
  • apt-get purge git
  • apt-get purge --auto-remove git

Remove Remote Origin

Merge Branch

  • git checkout -v new-branch
  • git add .
  • git commit –m "Some commit message"
  • git checkout master
  • git merge new-branch

Rename Remote

  • git remote rename origin github

  • git push --all origin

  • git branch -d localBranchName

  • git push origin --delete remoteBranchName

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