Skip to content

Instantly share code, notes, and snippets.

@aloon
Last active July 27, 2022 18:30
Show Gist options
  • Select an option

  • Save aloon/dde4cd8cf506ce7dd58d to your computer and use it in GitHub Desktop.

Select an option

Save aloon/dde4cd8cf506ce7dd58d to your computer and use it in GitHub Desktop.

Revisions

  1. aloon revised this gist Jun 14, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ antes se deberia haber hecho git fetch nombre_remote
    ## Clone, indicando nombre del remote
    git clone -o dropbox /Users/IT/Dropbox

    ### Crear repositorio para poder hacer pull
    ### Crear repositorio para aceptar push (servidor)
    git --bare init

    ### Crear enlace local para enviar a remote
    @@ -143,7 +143,7 @@ antes se deberia haber hecho git fetch nombre_remote
    http://progit.org/book/ch7-1.html

    ## Stash _escondite_
    el stash es como un commit temporal para poder cambiar de rama( por ejemplo)
    el stash es como un commit temporal para poder cambiar de rama (por ejemplo) Lo hace de todo tu working copy

    ### insertar en stash
    git stash
    @@ -155,7 +155,7 @@ el stash es como un commit temporal para poder cambiar de rama( por ejemplo)
    git stash clean

    ## Fusionar commits
    Fusionar los últimos 6 commits
    Fusionar los últimos 6 commits (importante no haber hecho push de alguno de los commits)
    git reset --soft HEAD~6
    git commit -m 'mensaje de commit'

  2. aloon created this gist Jun 14, 2014.
    193 changes: 193 additions & 0 deletions doc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,193 @@
    #GIT

    ## Configuracion inicial

    ### Global
    git config --global user.name "Alex Gonzalez"
    git config --global user.email miemail@domain.cat
    git config --global color.diff auto
    git config --global color.status auto
    git config --global color.branch auto
    git config --global color.interactive auto

    git config --global core.editor "mate -w"
    ó
    git config --global core.editor "mvim -f"


    ### Alias
    git config --global alias.st status
    git config --global alias.ci commit
    git config --global alias.co checkout
    git config --global alias.br branch
    git config --global alias.lol "log --abbrev-commit --graph --decorate --all --pretty=oneline"


    ## Comandos Basicos

    ###Inicializar repositorio
    git init

    ### Ver Estado
    git status

    ### Añadir al working
    git add .

    ### Commit working
    git commit -m "comment"

    ### Add y commit al working
    git commit -a -m "comment"

    ### Descartar todos los cambios
    git reset --hard

    ### Ver log con su SHA1_HASH
    git log
    git log --pretty=oneline
    git log --graph

    ### Borrar para siempre todo el historial hasta un punto
    git reset --hard SHA1_HASH
    Con --hard tambien borra los cambios
    con --soft no borra cambios

    ### Volver a un punto abriendo rama
    git checkout SHA1_HASH

    ## Ver ramas
    git branch

    ### Ver ramas incluyendo las remotas
    git branch -a
    antes se deberia haber hecho git fetch nombre_remote

    ## Bajarse una rama remota
    git checkout -t nombre_remote/nombre_rama

    ### Volver a la rama principal
    git checkout master

    ### Crear rama
    git checkout -b nombre_rama

    ### Volver a rama nombre
    git checkout nombre_rama

    ### Mezclar una rama de desarrollo "rama_tal" a la rama master
    git checkout master
    git merge rama_tal

    ### Mezclar una rama de desarrollo "rama_tal" a la rama master dejando un solo commit
    git checkout master
    git merge --squash rama_tal
    git commit -m


    ### Solucionar conflictos
    git mergetool

    ### Borrar rama_tal
    git branch -d rama_tal

    ### Canviar nombre de la rama actual
    git branch -m nuevo_nombre

    ### Descartar cambio de un fichero
    git checkout file file

    ### Descargar proyecto
    git clone git://sdf

    ## Clone, indicando nombre del remote
    git clone -o dropbox /Users/IT/Dropbox

    ### Crear repositorio para poder hacer pull
    git --bare init

    ### Crear enlace local para enviar a remote
    git add remote dropbox /carpeta/dropbox

    ### Crear remote ssh
    git remote add motespgit ssh://usuariogit@motespgit/var/cache/git/IphoneMotor.git

    ### Renombrar remote
    git remote rename old_name new_name

    ### Enviar al remoto dropbox
    git push dropbox master

    ### Actualizar local desde remoto una determinada rama
    git pull dropbox master

    ### Actualizar local desde remoto todas las ramas
    git fetch dropbox

    ### Solucionar conflictos
    git checkout --ours -- <file> # Obtener la versión del fichero en la rama actual
    git checkout --theirs -- <file> # Obtener la versión del fichero en la rama que se está fusionando con la actual

    ## Tags

    ### Ver tags
    git tag

    ### Añadir tag
    git tag -a v1.4 -m 'version 1.4'

    ### Ver todo referente a un tag
    git show v0.3

    ### External Merge and Diff Tools
    http://progit.org/book/ch7-1.html

    ## Stash _escondite_
    el stash es como un commit temporal para poder cambiar de rama( por ejemplo)

    ### insertar en stash
    git stash

    ### recuperar stash
    git stash apply

    ### limpiar stash
    git stash clean

    ## Fusionar commits
    Fusionar los últimos 6 commits
    git reset --soft HEAD~6
    git commit -m 'mensaje de commit'

    ## Eliminar

    ## Eliminar tag
    git tag -d <tag>

    ## Eliminar rama
    git br -d <rama>

    ## Eliminar tag/rama remota
    git push dropbox :<tag o rama>

    ## Eliminar tag que ya existe una rama con el mismo nombre
    git push origin :refs/tags/<tag>

    ## Eliminar rama que ya existe un tag con el mismo nombre
    git push origin :refs/heads/<rama>


    ---
    ## Bibliografía
    ### 85% cocoa
    * [Episodio0](http://josealobato.tumblr.com/post/765059454/tutorial-de-git-episodio-0)
    * [Episodio1](http://josealobato.tumblr.com/post/769815718/tutorial-de-git-episodio-1)

    ### Libro
    * [GitMagic](http://www-cs-students.stanford.edu/~blynn/gitmagic/intl/es/book.html)
    * [ProGit](http://progit.org/)
    * [ProGit es](http://librosweb.es/pro_git/)

    ### Blogs
    * [Git Evangelist](http://gitevangelism.blogspot.com/)
    * [Chuleta](http://www.edy.es/dev/docs/git-guia-rapida/)