Skip to content

Instantly share code, notes, and snippets.

@analistacarlosh
Last active February 19, 2020 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save analistacarlosh/5c3812df9adf3970a9b5 to your computer and use it in GitHub Desktop.
Save analistacarlosh/5c3812df9adf3970a9b5 to your computer and use it in GitHub Desktop.
Basics Git commands to use

Referências de GIT

referência: http://git-scm.com/book/pt-br/Git-Essencial-Tagging

git init

git config --global user.name "" git config --global user.email "" git config list

git clone git://github.com/repositorio

git remote -v git remote add [apelido] [url-remote]

git remote show [nome-remote] git branch --remotes

listar branch git ls-remote

git ls-remote --tags

Deletar branch remote: git push origin --delete $branchname

git checkout [nome-branch] git branch [nome-branch]

git checkout -b new-branch

git merge --no-ff [nome-branch] opção --no-ff força a criação de um commit, facilitando o reverse.

http://blog.gustavohenrique.net/2011/03/comandos-basicos-do-git/

git rm --cached

git reset --hard HEAD~1 (volta ao último commit)

Para recuperar um commit do reset – HARD basta usar git reflog

git reset --soft HEAD~1 (volta ao último commit e mantém os últimos arquivos no Stage) git reset --hard XXXXXXXXXXX (Volta para o commit com a hash XXXXXXXXXXX)

git revert HEAD~3

==============================================================================================

Baixar branch remoto no local

 sudo git remote update
 sudo git checkout sprint-4
 sudo git pull -u origin sprint-4

http://blog.gustavohenrique.net/2011/03/comandos-basicos-do-git/

====================================================

git clone url

git add name-file

git commit -m "mensagem do commit"

git pull origin master

git push origin master

git branch novo-branch

git log

git log --stat (exibe o log e arquivos que foram commitados)

================================================== Ignorar chmod dos arquivos no git

git config core.fileMode false

================================================= REMOVER ARQUIVO do stagey

git clean -f arquivo.txt

alterar mensagem do commit

git commit --amend -m "my new awesome message"

================================================= Trabalhando com Tag - ref: https://git-scm.com/book/pt-br/v1/Git-Essencial-Tagging

Tags Anotadas Criando uma tag anotada em Git é simples. O jeito mais fácil é especificar -a quando você executar o comando tag:

$ git tag -a v1.4 -m 'my version 1.4'

Compartilhando Tags git push origin [nome-tag] ou git push origin --tags

Criando branch a partir de uma tag

git branch newbranch v1.0

git checkout -b newbranch v1.0

git tag -d 12345 git push origin :refs/tags/12345

=============== referencia: http://pt.stackoverflow.com/questions/19393/como-voltar-o-projeto-a-um-commit-espec%C3%ADfico#_=_ https://git-scm.com/book/pt-br/v1/Ferramentas-do-Git-Fazendo-Stash

git rm -r --cached

Untrack files already added to git repository based on .gitignore Step 1: Commit all your changes. Before proceeding, make sure all your changes are committed, including your .gitignore file. Step 2: Remove everything from the repository. To clear your repo, use: git rm -r --cached . ... Step 3: Re add everything. git add . Step 4: Commit. git commit -m ".gitignore fix"


reference: https://dev.to/ben/git-standup-how-did-i-ever-live-without-you

remove files from cache, usefful with add .gitignore in the new project

git rm -r --cached .

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