De Wiki inetshell
Saltar a: navegación, buscar

Renombrar branch[editar]

Rename your local branch.
If you are on the branch you want to rename:
git branch -m new-name

If you are on a different branch:
git branch -m old-name new-name

2. Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name

3. Reset the upstream branch for the new-name local branch.
Switch to the branch and then:
git push origin -u new-name

Corregir commit anterior[editar]

git commit --amend  --author "Juan Manuel Carrillo Moreno <[email protected]>" -m "Added Jenkinsfile"

Activar colores[editar]

  • Agregar a ~/.gitconfig:
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true

Tutorial de Git[editar]


Ver historial de commits[editar]

git log
git log --pretty=oneline
git log --pretty=format:"%h - %an, %ar : %s"
git log -p
git log --oneline
git log -- index.html

Revertir repo local[editar]

git reset

git reset --hard 19281948

git reset --hard HEAD

git revert

Revertir un cambio antes de commit[editar]

Git: revert (reset) a single file

git checkout -- filename

Revertir un cambio despues de commit[editar]

git revert HEAD~1..HEAD

Github usando SSH[editar]

Connecting to github with SSH

Hacer merge de un branch a Master[editar]

git checkout master
git merge develop
git push


Crear un tag[editar]

git tag -a v0.1 -m "program v0.1"
git tag
git show v0.1
git tag -l
git push origin v0.1

Buscar un tag a partir de un commit[editar]

git describe --tags <commit-id>

Recuperar un commit perdido[editar]

git reflog

Fork y subir commit a upstream[editar]

git clone ssh://[email protected]/~user/project.git project
git remote add upstream ssh://[email protected]/project/project.git
git remote -v
vi file.txt
git status
git stash
git checkout -b bugfix/test
git stash pop
git status
git add file.txt
git commit -m "My commit"
git push origin

Crear branch desde shell[editar]

git checkout -b master
git push -f origin master
git fetch origin master
git checkout -b develop origin/master
git push --set-upstream origin release/v0.5.4
git push origin develop

Eliminar branch desde shell[editar]

git branch -d develop

Archivar git[editar]

git archive --format=tar --remote=ssh://[email protected]/project/project.git v0.5.4 | gzip > project-0.5.4.tar.gz

Omitir cambios en permisos[editar]

git config core.fileMode false

Como hacer un push cuando el origen cambio[editar]

  • Repositorio con cambio local: bugfix/docker
  • Repositorio origen: origin/develop
git checkout bugfix/docker
git fetch origin; git reset --hard origin/develop
git log
git status
git pull
git status
git log

Conectar a repositorio remoto[editar]

git remote add origin


Remover submodulo[editar]

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule