Git reset

git reset HEAD file	Eliminar del stage un cambio
git reset code	Deshace un commit
git reset --hard code	Deshace commit y los cambios locales
git reset --soft code	Deshace commit y lo deja en el stage


Git diff & log

git diff code1 code2 Muestra difrencia entre dos commit
git log --oneline Muestra code y mensaje
git log --oneline --decorate
git diff HEAD~1 HEAD~2 Compara dos commit

Git revert

Para esto puedes utilizar el comando revert, este comando no elimina 
ningun commit por el contrario crea una nueva versión que revierte 
los efectos del commit indicado

git revert 90e3675

Para obtener el commit que deseas revertir puedes utilizar el comando git log

git log --oneline --all

https://www.youtube.com/watch?v=4SwaV29SpIc

git revert HEAD
git revert --no-commit HEAD Tengo en el stage el cambio
git revert --no-commit HEAD~1 Vuelvo atras otro commit
git revert --continue Terminar el revertir

Crear alias para git

More information here

git log --oneline --decorate --all --graph

Crear un alias git lodag

git config --global alias.lodag 'log --oneline --decorate --all --graph'

Listar los alias

git config --global --get-regexp alias

Eliminar un alias

git config --global --unset alias.alias_del_comando

Pull tags from repository

git fetch --all

Deshacer la fusion

git merge --abort

Git tag

Create tag

git tag v0.0
git tag -a  -m "message"

Tag in commit

git tag v0.0 CodeHash

List tags

git tag

Push tag

git push --tags

Delete tag local and remote

git tag -d NameTag
git push origin :refs/tags/NameTag
ó
git push --delete origin tagname

List tags by filter

git tag -l "v0.*"

Details tag or branch

git show v0.2
git show master

Git stash

git stash -h
git stash list
git stash apply
git stash save "MSG"
git stash pop 

Remote repositories

Repositorios REMOTOS

git remote add origin https://gitlab.com/carlosamores93/git.git

Push origin

git push origin NameBranch

New reposotory conect

git clone urlRepository 

Git rebase

Rebase es un comando que reescribe el historial
El merge tiene trazabilidad pero un rebase no tiene

Rename last commit

git commit --amend
git push origin NameBranch -f

Rename commits

git rebase -i HEAD~N
    Move to the lines of the commit message you want to change and replace pick with reword
git push --force branch-name

Squash commits

git rebase -i HEAD~4
    Move to the lines of the commit message you want to change and replace pick with squash
git push origin NameBranch --force

Git cherry pick

https://www.atlassian.com/git/tutorials/cherry-pick

git checkout NameBranch
git cherry-pick commitSha

Git diff and git apply

git diff > changes.txt
git apply changes.txt

 

 


Rename branch

git branch -m OLD_NAME_BRANCH NEW_NAME_BRANCH
git push origin :OLD_NAME_BRANCH NEW_NAME_BRANCH
git push origin -u NEW_NAME_BRANCH