-
-
Save RodolVelasco/e6af0d59273e899b0d02e8eb37ff2383 to your computer and use it in GitHub Desktop.
git commands |
For the First commit ever, adding remote repo already created in github
Iniciar el repo
git init
Añadir files
git add .
Primer commit with message
git commit -m "Initial commit"
Add git remote repo
git remote add origin https://github.com/RodolVelasco/fortuna.git
Push to the repo
git push -u origin master
Código desde distintas máquinas
Cuando yo mismo ande metiendo código en distintas máquinas, puedo usar este comando para halar el código del repositorio
git pull origin master
GIT comandos básicos
Comparar
diff -u old.html new.html
Log de commits
git log
Comparar versiones del mismo file por id commit
git diff commit_id1 commit_id2
Regresar a una version previa (checkout)
git checkout id_commit
Para crear un checkout con una nueva branch (utilizar nuevamente checkout para lograr este comportamiento)
git checkout -b branch_name
Diferencia entre working directory and staging
git diff
Diferencia entre staging y repository
git diff --staged
Discard any changes in either the working directory or the staging area.
Si se borra, los cambios no pueden ser recuperados
git reset --hard
BRANCHES
Muestra listado de branches
git branch
Crear un branch
git branch any_argument
Para ubicarse en un branch
git checkout branch_name
Ver log manera resumida
git log --graph --oneline master branch_name
Remeber that HEAD means current commit.
Un checkout sobre un commit se vería como la siguiente imagen. Se vería sin ninguna branch
Este tipo de commits no se muestran con git log
ya que no pertenece a ninguna branch
Para incorporarlo vamos a necesitar hacer un git checkout -b new_branch_name
esto equivale a hacer dos comandos: git checkout y luego git branch
git show commit_id
Para borrar un branch
git branch -d branch_name
Lo querré borrar luego de haber hecho un merge. Los commits del branch no se pierden ni tampoco los del padre.
Add a git remote repository from Github
git remote add origin https://github.com/RodolVelasco/fortuna.git