Skip to content

Latest commit

 

History

History
220 lines (157 loc) · 4.55 KB

git.md

File metadata and controls

220 lines (157 loc) · 4.55 KB

Git

Comandos

Adicionar diretório remoto:

git remote add origin [email protected]:vtmx/repositorio.git

Adiciona repositorio local para remoto:

git push -u origin branch

Faz upload das mudanças:

git push origin branch

Geralmente usado no início:

git push -u -f origin main

Visualiza repositórios remotos conectados:

git remote -v

Remove repositório remoto:

git remote rm origin

Faz upload para o branch principal:

git push

Baixa mudanças do repositório remoto:

git pull

fatal: refusing to merge unrelated histories - Força pull:

git pull origin branchname --allow-unrelated-histories

Soluções

# Rejeitar
! [rejected] master -> master (fetch first)
git push --force origin master

# Cria um novo branch e entra nele
git checkout -b novo-branch

Push

git init
git add -A
git commit -m 'Added my project'
git remote add origin [email protected]:sammy/my-new-project.git
git push -u -f origin main

Netlify

# Branch deploy
dev

# Build command
hugo

# Publish directory
public

Limpando cache

# Remove cache
git rm -r --cached .

# Adiciona todos os arquivos novos ou modificados para a área de stage
git add -A

# Adicionando todos os arquivos e diretorios modificados
git add .

# Não sei
git checkout HEAD -- my-file.txt # remove arquivo do stage
git rm --cached <filePath> #unstage a single file
git reset #unstage all staged files
git commit -am 'git cache cleared'

Branch

# Cria novo branch e vai para ele
git checkout -b <branch_name>

# Vai para o branch
git checkout <branch_name>

# Remove branch local
git branch -d <branch_name>
git branch -D <branch_name>

# Remove branch remoto
git push --delete <remote_name> <branch_name>
git branch -d <branch_name>

# Set your config
git config --global user.name "name"
git config --global user.email "email"

# Remove mensagem de erro CRLF
git config --global core.autocrlf false

# Adiciona ssh para não pedir senha
eval (ssh-agent -c)
ssh-add ~/.ssh/id_rsa

# Verifica se a chave no git está correta
ssh -T [email protected]

Exibe a hash para poder comparar com as do github.

ssh -l

eval (ssh-agent c)

# Não tenho certeza se isso funcionou nessa etapa:
echo "set SSH_AUTH_SOCK \"$SSH_AUTH_SOCK\"; export SSH_AUTH_SOCK"
echo "set SSH_AGENT_PID \"$SSH_AGENT_PID\"; export SSH_AGENT_PID"

ssh-add ~/.ssh/id_ed25519

Manjaro foi necessário instalar o x11-ssh-askpass

https://archlinux.org/packages/community/x86_64/x11-ssh-askpass/

Nomes de commit

"Fix", "Add", "Change"

Clone com o mínimo de commits

git clone --depth 1

Clone com um único branch

git clone [url] --branch [branch] --single-branch

Resolvendo problema arquivos grantes

# GH001: Large files detected. You may want to try Git Large File Storage
# 2 número de commits para trás
git rebase -i HEAD~2

# s no commmit que deseja remover, salva
# https://youtu.be/TXSmxtU2tOk?feature

# Ou
git reset --soft HEAD^2

Lembrar credencial

git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=600'

Links