Algunos comandos usados en proyectos:
Operaciones locales:
working directory -> staging area -> git repository
# Situarte en la rama desde donde quieres crear la rama
git checkout develop
# Comprobar que se tienen los últimos cambios
git fetch
git pull
# Crear la rama
git checkout -b feat/new-feature
staging area
todos los ficheros# Ver el estado actual de los cambios (qué está en el índice para subir)
git status
# Comprobar en VS Code las diferencias de los ficheros para asegurar que lo que subes es lo que quieres subir
git add .
staging area
git reset HEAD -- <file>
working directory
(todavía no subidos al staging area
)git checkout .
staging area
al git directory
git commit -m "Commit message"
git push origin HEAD
# Asegurarte que estás en tu rama
git status
# Sincronizarte con el remoto
git fetch
git rebase origin/master
# resolver conflictos si los hubiera
git add .
git rebase —continue
# subir la rama rebasada a remoto con -f
git push origin "feature-branch" -f
http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
Ejemplo: Combinar los últimos 4 commits tuyos en el primer commit de la lista:
git rebase -i HEAD~4
# Ejemplo (:wq al final para guardar como en vi)
pick 01d1124 Adding license
squash 6340aaa Moving license into its own file
squash ebfd367 Jekyll has become self-aware.
squash 30e0ccb Changed the tagline in the binary, too.
git add <file1> <file2> # si conflictos
git rebase —continue # si conflictos
git push origin <branchname> -f
Ejemplo: quieres añadir algo al último commit
# Haces los cambios
git add <file1> <file2>
git commit --amend
git push origin <branchname> -f
git reset —hard origin/rama
ó
git checkout -B master origin/master
git push -d origin feat/feature-branch
git branch -D feat/feature-branch
git branch | grep -v "master" | xargs git branch -D
https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/
git branch -m feat/MHF-725-params
git push origin :feat/MHF-841-params feat/MHF-725-params
git push origin -u feat/MHF-725-params
# Guardar
git stash
# Recuperar borrando el stash
git stash pop
# Recuperar manteniendo el stash
git stash apply
git log --all --grep='Build 0051'
git log index.html
git diff 307f6132baddc1778217afa266f992005e8267db a76f3214d316acde9a0b8747744f35faae55e91d
# Remote:
git push --delete origin tagname
# Local:
git tag --delete tagname
git tag -a 3.26.0 -m "Version 3.26.0”
git push origin 3.26.0
git log --graph --oneline --all
:cq
.git
git init .
git pull --allow-unrelated-histories