You are on page 1of 7

1.

-Instalar GIT y Git-flow


En el servidor:
--------------
# sudo apt-get install git ( o puede ser git-core )
# wget --no-check-certificate -q -O - https://github.com/nvie/gitflow/ra
w/develop/contrib/gitflow-installer.sh | sudo bash
En el servidor:
--------------
Crear una carpeta especifica para el repositorio
$ mkdir nuestro-proyecto
$ cd nuestro-proyecto
$ git init
$ git-flow init
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master]
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? [feature/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? [] v
Al ejecutar el ltimo comando, entramos en un men interactivo que nos va preguntand
o las opciones que aparecen arriba:
Al inicializar git-flow, nos pregunta el nombre de la rama de produccin y de la r
ama de desarrollo (master y develop respectivamente). Seleccionamos los nombres
por defecto.
Despus nos preguntar los prefijos que asignar a las ramas de tipo feature, release,
hotfix y support. Volvemos a seleccionar los nombres por defecto.
Por ltimo, nos pregunta el prefijo que queramos utilizar para etiquetar las versi
ones. Puede colocarse "v" para que queden asi: v-0.1
En el cliente:
-------------
(Debe instalarse tambien. Mismos 2 pasos que para el servidor).
Ir o crear la carpeta donde se quiere descargar el repositorio
$ cd nuestro-proyecto
Clonar el repositorio (servidor de ejemplo: 192.168.0.1) (Aqui descargamos la ul
tima version)
$ git clone usuario@192.168.0.1:/home/usuario/nuestro-proyecto
Teclear la clave del usuario ssh (debe existir en el servidor).
///***********************************////
///***** ACTUALIZACION DIC/2013 ******////
///***** EN EL SERVIDOR **************////
mkdir proyecto.git/
cd proyecto.git/
git init
git-flow init
git config core.sharedrepository true
git config receive.denyCurrentBranch warn
chmod -R 777 .git/*
git checkout master
cd ..
*** DESPUES QUE ACTUALICEN Y CHEQUEAR ***
cd /opt/git/proyecto.git/
git branch -av
git checkout master
git merge develop
///**********************************////
///***** EN LOS CLIENTES ************////
git config --global user.name "Nombre"
git config --global user.email "correo@dominio"
git clone usuario@192.168.10.231:/carpeta/proyecto.git
cd proyecto/
git checkout master
nano commits.txt
git branch -av
git remote -v
git add .
git tag v-0.1
git commit -a -m "Primer Commit"
git diff
git status
git push origin v-0.1
**** SI LO ACTUALIZO OTRO, PRIMERO DESCARGAR ****
git pull
nano commits.txt
git add .
git commit -a -m "Tercero Commit"
git diff
git status
git push
git log --stat develop
///**********************************////
Comandos funcionales para trabajar como programador en la rama DEVELOP!!!
La rama MASTER es la definitiva. Solo se actualiza cuando los cambios
estan verificados y funciona todo bien.
155 cd www/mis-proyectos
156 git clone atlante@192.168.10.250:/home/sysadmin/git/proyecto-ceunefa
158 cd proyecto-ceunefa/
159 git branch -av
ME CAMBIO A LA RAMA DEVELOP PARA TRABAJAR DESDE AHI*****
160 git checkout develop
161 git branch -av
COPIE LA CARPETA ESTILOS********************************
Y AGREGO AL INDICE LOS ARCHIVOS QUE COPIE O MODIFIQUE
163 git add .
164 git commit -a -m "Se agrego la carpeta de estilos"
165 git diff
166 git status
ACTUALIZO LA RAMA DEVELOP DEL SERVIDOR******************
SUBIENDO LOS ARCHIVOS QUE AGREGUE
167 git push
168 git branch -av
COPIE LA CARPETA MODELO*********************************
169 git add .
170 git diff
171 git commit -a -m "Se agrego la carpeta modelo de la BD"
172 git status
173 git push
174 git branch -av
COPIE LA CARPETA INC************************************
175 git add .
176 git commit -a -m "Se agrego la carpeta inc con imagenes y scripts"
177 git diff
178 git status
179 git push
COPIE LA CARPETA CLASES*********************************
180 git add .
181 git commit -a -m "Se agrego la carpeta de clases"
182 git diff
183 git status
184 git push
COPIE LA CARPETA CONTROLADORES**************************
185 git add .
186 git commit -a -m "Se agrego la carpeta de controladores. Primer modulo. S
eguridad y usuarios."
188 git diff
189 git status
190 git push
COPIE LA CARPETA VISTAS*********************************
191 git add .
192 git commit -a -m "Se agrego la carpeta de vistas. Pantalla Principal, Ini
cio de sesion y Seguridad de usuarios"
193 git diff
194 git status
195 git push
AQUI ELIMINE 2 ARCHIVOS*********************************
196 git diff
197 git status
198 git commit -a -m "Se eliminaron 2 archivos. modeloPersonal.php y menu.ope
rador.php"
199 git push
200 git branch -av
SE DEBERIA SUBIR SOLO LA RAMA DEVELOP*******************
Y DEJAR QUE EL ADMINISTRADOR MEZCLE LAS RAMAS
DESPUES DE HABER APROBADO LOS CAMBIOS
PERO AQUI ME CAMBIE A LA RAMA MASTER
Y LA MEZCLE CON LA RAMA DEVELOP
201 git checkout master
202 git merge develop
203 git commit -a
204 git diff
205 git push
CUANDO HICE PUSH AQUI ME DIO UN ERROR.
EN LA PARTE SIGUIENTE DIGO COMO SOLUCIONARLO
////*******************************////
Si al hacer push a la rama MASTER sale este error:
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repositor
y
remote: error: is denied, because it will make the index and work tree inconsi
stent
remote: error: with what you pushed, and will require 'git reset --hard' to ma
tch
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable
t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing in
to
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in so
me
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, s
et
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
En el servidor hay que ejecutar este comando:
git config receive.denyCurrentBranch warn
Y "al parecer" cada vez que se haga un push por alguien
ejecutar este otro:
git reset --hard
////*****************************//// DIC 2013
198 sudo apt-get install git-core
199 git config --global user.name "esfinge"
200 git config --global user.email "papulido@unefa.edu.ve"
201 git clone esfinge@192.168.10.231:/var/www/unefa_ce
202 sudo chmod 777 -R unefa_ce/
204 cd unefa_ce/
206 nano README.md
207 git checkout develop
208 git branch -av
209 git remote -v
210 git add .
211 git commit -a -m "Modificacion de prueba al archivo README.md"
212 git diff
213 git status
214 git push
215 git status
*******************
Se va a fusionar la rama desarrollo en la rama master, nos situamos en la rama m
aster y ejecutamos
001 git checkout desarrollo
002 git rebase master
Este comando rebase mueve todos los commit de la rama desarrollo a continuacin de
l ltimo commit de la rama master. A continuacin actualizamos el apuntador master
.
001 git checkout master
002 git merge desarrollo
Realiza un fast-forward y el apuntador master se sita en el ltimo commit, ahora te
nemos un historial lineal.
- See more at: http://rooteando.com/ramas-y-fusiones-en-git#sthash.4YFXCkm7.dpuf
////********************************////
Mas comandos
**********************
Descargar los ultimos cambios. Todos los tuyos se perderan
$ git fetch origin
$ git reset --hard origin/master
Igual que git push
$ git merge origin
Descartar cambios locales
$ git stash
Agregar otro archivo despues del comando: git commit
$ git add archivo_olvidado
$ git commit --amend
Entrar a la carpeta
$ cd nuestro-proyecto
Utilizar el repositorio
Hacer cambios: crear archivos, copiar carpetas, modificaciones, etc.
Ver las ramas existentes:
$ git branch -av
Ver en cual rama estoy:
$ git branch
Crear una rama (ej. develop (que ya deberia existir)):
$ git branch develop
Para saltar a una rama (ej. develop):
$ git checkout develop
Crear una rama a partir de otra (se creo feature-H-1):
$ git checkout -b feature-H-1 develop
Hacer el primer commit
$ git commit -a -m "Primer commit"
Hacer el primer push y crear la rama 'master'
$ git push origin master
Agregar un repositorio remoto
$ git remote add web 192.168.10.231:/opt/git/unefa_ce.git
Eliminar un repositorio remoto
$ git remote rm repositorio

*****************************
Haciendo pruebas:
$ git branch -av
* master b7bb737 Initial commit
remotes/origin/HEAD -> origin/master
remotes/origin/develop b7bb737 Initial commit
remotes/origin/master b7bb737 Initial commit
$ git branch develop
$ git branch
develop
* master
$ git checkout -b feature-H-1 develop
Switched to a new branch 'feature-H-1'
$ git branch -av
develop b7bb737 Initial commit
* feature-H-1 b7bb737 Initial commit
master b7bb737 Initial commit
remotes/origin/HEAD -> origin/master
remotes/origin/develop b7bb737 Initial commit
remotes/origin/master b7bb737 Initial commit
Aqui hice cambios en la carpeta del proyecto
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff feature-H-1
Already up-to-date.
$ git branch -d feature-H-1
Deleted branch feature-H-1 (was b7bb737).
$ git-flow feature start H-2
Switched to a new branch 'feature/H-2'
Summary of actions:
- A new branch 'feature/H-2' was created, based on 'develop'
- You are now on branch 'feature/H-2'
Now, start committing on your feature. When done, use:
git flow feature finish H-2
Aqui hice cambios en la carpeta del proyecto
Ahora preparo la version 1.0
$ git flow release start 1.0
Switched to a new branch 'release/1.0'
Summary of actions:
- A new branch 'release/1.0' was created, based on 'develop'
- You are now on branch 'release/1.0'
Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:
git flow release finish '1.0'
$ git checkout master
$ git push
***************************+*+
Cmo borrar el ltimo commit en git
Dic 16 2010
En este post se explica con dos sencillos comandos como borrar un commit de git
tanto si no se ha hecho un push como si ya se ha hecho.
El comando a ejecutar en git para borrar un commit del que todava no se ha hecho
push es:
git reset --hard HEAD~1
Como apunte tener en cuenta que HEAD~1 es una abreviatura del ltimo commit antes
del HEAD. Con el hard aseguramos que cualquier cambio hecho se pierda al volver a
la versin anterior. En vez de hard se puede usar soft para evitar perder estos cam
bios, que aparecern como cambios a los que se debe hacer un commit.
Si ya se ha hecho un push del commit que se quera borrar, lo mejor es hacer un nu
evo commit que lo borre mediante un `revert'. De este modo aseguramos que si alguien
ya se ha bajado el commit que queramos borrar, pueda arreglar el problema simple
mente haciendo un pull. Por tanto, el comando a ejecutar para borrar un commit a
l que ya se ha hecho un push es:
git revert HEAD
***************************
Antiguos comandos:
293 mkdir serviciotic
294 cd serviciotic
295 git init
296 echo "Servicio TIC" > Leeme.txt
297 git add Leeme.txt
298 git commit -m 'versin inicial del proyecto'
299 git status
300 cp ../serviciotic.primera.version/principal.php principal.php
301 git status
302 cat .gitignore
303 ls -l
304 echo "*~" > .gitignore
305 git status
306 git diff
307 git commit
308 cd ..
309 cd serviciotic
310 git remote add origin atlante@192.168.0.250:/home/atlante/git/serviciot
ic.git
311 git push origin master
312 ssh atlante@192.168.0.250
313 git remote
314 git remote rm origin
315 cd ..
316 scp -r serviciotic atlante@192.168.0.250:/home/atlante/git/
317 ssh atlante@192.168.0.250
318 cd serviciotic
319 git status
320 git rm principal.php
321 ls -l
322 nano principal.php
323 git status
324 git diff
325 git remote add origin atlante@192.168.0.250:/home/atlante/git/serviciot
ic
326 git commit -m 'versin inicial del proyecto'
327 git remote
328 git push origin develop

You might also like