Recent comments

Guia de Git



Estatus principal de GIT



LOCAL

Ejecuta para inicializar un proyecto de 0
git init

Ejecuta para  preparar al staging area
git add .

Verificar status actual
git status

Crea un snap de tu proyecto
git commit -m "comment"

Si deseas eliminar los archivos en rojo puedes usar
git clean -f o -d 
o
git clean -fd

CONFIGURAR USUARIO / OTROS

git config --global user.name "name" 
git config --global user.email "name@gmail.com"

Para ignorar ciertos archivos a subir solo crea en la raíz
.gitignore
carpeta
archivo.txt

DOWNLOAD PROJECT

Clonar un repositorio existente
git clone https://gitlab.com/user/learn_git2.git

Bajar la ultima version
git pull

Para cambiar de rama
git branch <name>

Para ver todas las ramas
git branch

Para cambiarte a commit especifico
git checkout <hash>
donde hash es el numero del commit a realizar este te pone el puntero en head

UPLOAD PROJECT

Agregar el repositorio remoto
git remote add origin https://gitlab.com/ivxnlm/learn_git2.git
Sube tus cambios al repositorio
git push -u origin master



Working New Project

Creas el proyecto e inicias git en la carpeta
git init

Listar repositorios
git remote -v

Reemplazar repositorio
git remote set-url origin http:url.com.git

Agregar el repositorio remoto
git remote add origin https://gitlab.com/user/learn_git2.git

Creas una nueva rama
git branch rama1

Sube tus cambios al repositorio con la nueva rama
git push -u origin rama1

Si tienes cambios basura en tu proyecto y quieres bajar nuevamente tu ultimo estado remoto debes usar (se borraran tus cambios locales y los commits locales)
Si solo dejas la rama te deja a tu ultimo commit local :)
git reset --hard origin/branch_to_overwrite
Ahora ejecuta lo siguiente para sincronizar con lo remoto
git pull

Si quieres reemplazar tu master remoto por otra branch local
Ya estando en tu branch que quieres que sea tu master ejecuta este comando para borrar tu rama master local
git branch -D master
Luego ejecuta este comando para convertir tu rama actual en tu nueva master y posicionarte en ella
git checkout -b master
Finalmente manda tus nuevos cambios a tu rama master remota forzando a update.
git push -f origin master 

Para agregar la llave ssh:

  1. Go to "Git Bash" just like cmd. Right click and "Run as Administrator".
  2. Type ssh-keygen
  3. Press enter.
  4. It will ask you to save the key to the specific directory.
  5. Press enter. It will prompt you to type password or enter without password.
  6. The public key will be created to the specific directory.
  7. Now go to the directory and open .ssh folder.
  8. You'll see a file id_rsa.pub. Open it on notepad. Copy all text from it.
  9. Go to https://gitlab.com/profile/keys .
  10. Paste here in the "key" textfield.
  11. Now click on the "Title" below. It will automatically get filled.
  12. Then click "Add key".






No hay comentarios.