Creating Snapshots

  • Inicializando um repositório

git init
  • Prepara o diretório atual e todo o seu conteúdo

git add .
  • Ver status completo

git status
  • Ver status resumido

git status -s
  • Committing the staged files

git commit -m “Message” #Commits with a one-line message
git commit #Opens the default editor to type a long message 
  • Ignorando a área de preparação (commit)

git commit -am “Message” 
  • Removendo arquivos

git rm file1.js # Removes from working directory and staging area
git rm --cached file1.js # Removes from staging area only 
  • Renomeando ou movendo arquivos

git mv file1.js file1.txt
  • Visualizando as alterações encenadas/não encenadas

git diff # Shows unstaged changes
git diff --staged # Shows staged changes
git diff --cached # Same as the above
  • Visualizando o histórico

git log # Full history
git log --oneline # Summary
git log --reverse # Lists the commits from the oldest to the newest 
  • Viewing a commit

git show 921a2ff # Shows the given commit
git show HEAD # Shows the last commit
git show HEAD~2 # Two steps before the last commit
git show HEAD:file.js # Shows the version of file.js stored in the last commit 
  • Desfazer preparação de arquivos (desfazendo git add)

git restore --staged file.js # Copies the last version of file.js from repo to index 
  • Descartando alterações locais

git restore file.js # Copies file.js from index to working directory
git restore file1.js file2.js # Restores multiple files in working directory
git restore . # Discards all local changes (except untracked files)
git clean -fd # Removes all untracked files 
  • Restaurando uma versão anterior de um arquivo

git restore --source=HEAD~2 file.js

Last updated