De Wiki inetshell
Saltar a: navegación, buscar

Renombrar branch[editar]

https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/

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]

https://unix.stackexchange.com/questions/44266/how-to-colorize-output-of-git

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

Tutorial de Git[editar]

[1]

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

https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History

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

https://githowto.com/merging_back_to_master

Tagging[editar]

Crear un tag[editar]

https://git-scm.com/book/en/v2/Git-Basics-Tagging

https://stackoverflow.com/questions/18216991/create-a-tag-in-github-repository

https://stackoverflow.com/questions/5195859/how-to-push-a-tag-to-a-remote-repository-using-git

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]

https://stackoverflow.com/questions/1474115/how-to-find-the-tag-associated-with-a-given-git-commit

git describe --tags <commit-id>

Recuperar un commit perdido[editar]

http://gitready.com/advanced/2009/01/17/restoring-lost-commits.html

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]

https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes

git config core.fileMode false

Como hacer un push cuando el origen cambio[editar]

https://stackoverflow.com/questions/22320058/git-first-rewinding-head-to-replay

  • 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 https://github.com/user/repo.git

Submodules[editar]

https://www.youtube.com/watch?v=UQvXst5I41I

https://git-scm.com/book/en/v2/Git-Tools-Submodules

Remover submodulo[editar]

https://gist.github.com/myusuf3/7f645819ded92bda6677

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