elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


+  Foro de elhacker.net
|-+  Sistemas Operativos
| |-+  GNU/Linux (Moderador: MinusFour)
| | |-+  Git en GNU/Linux tengo problemas y dudas :(
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Git en GNU/Linux tengo problemas y dudas :(  (Leído 5,601 veces)
Diabliyo


Desconectado Desconectado

Mensajes: 1.441


shell# _


Ver Perfil WWW
Git en GNU/Linux tengo problemas y dudas :(
« en: 8 Enero 2011, 02:18 am »

Buenas...

Me he instalado localmente el GIT para mantener bien organizados mis proyectos, esto con la finalidad de subir mis cambios a mi Servidor Dedicado (tambien he instalado GIT igual que en mi Equipo Local).

En si el proceso de instalacion es sencillo, simplemente se compilan las fuentes y ya esta funcionando...

Para tener mejor organizado mi equi Local, he creado un directorio (mas NO un usuario) en /home/, llamada: git (/home/git), dentro pongo mis proyectos, asi:

Código:
shell# cd /home/git/
shell# mkdir proyecto1.git
shell# cd proyecto1.git/
shell# git init
shell# echo "prueba" > dato.txt
shell# git add .

OJO: todo lo realizo como ROOT.

Tambien configure mi Apache para visualizar el git: http://localhost/git...

MI PROBLEMA es que no se como puedo por ejemplo, con mi cuenta de usuario normal, una vez que he creado mis repositorios por ejemplo en: /home/miusuario/Documentos/git/proyectA.git, como puedo subirlo a mi Equipo Local ?...

Intente asi:

Código:
# OJO: soy usuario comun aqui, NO soy root

shell$ cd /home/miusuario/Documentos/git/proyectoA.git/

shell$ git push http://localhost/git  # sale error
fatal: http://localhost/git/info/refs not found: did you run git update-server-info on the server?

shell$ git push git://localhost/git
fatal: The remote end hung up unexpectedly

Alguien que me oriente !!...

Saludos !


En línea

Diabliyo


Desconectado Desconectado

Mensajes: 1.441


shell# _


Ver Perfil WWW
Re: Git en GNU/Linux tengo problemas y dudas :(
« Respuesta #1 en: 11 Enero 2011, 03:57 am »

Creo que ya lo voy logrando, pero algo falla :S, miren les relato desde el principio:

1- Me conecto al Servidor Dedicado y hago:
Código:
shell# ssh -l miusuario miservidor.com
shell$ su
Password:

shell# cd /home/git/
shell# mkdir prueba
shell# cd prueba/
shell# git init
shell# echo "estoy en servidor dedicado" > dedicado.txt
shell# git add .
shell# git commit -am "Srv Dedicado"
shell# exit
shell# exit

2- En mi servidor Local
Código:
shell$ su
Password:

shell# cd /home/git/
shell# mkdir prueba
shell# cd prueba/
shell# git init

3- Ahora la sincronicazion de Repos
Código:
shell# git pull diabliyo@git.miservidor.com:/home/git/data
diabliyo@git.miservidor.com's password:
From git.miservidor.com:/home/git/data
 * branch            HEAD       -> FETCH_HEAD
Already up-to-date.

4- Creacion del Documento en Local
Código:
# en Servidor Local, ya esta el archivo "dedicado.txt"

shell# echo "estoy en el local" > local.txt
shell# git add .
shell# git commit -am "Srv Local"

# subiendo novedades
shell# git push diabliyo@git.miservidor.com:/home/git/data
diabliyo@git.crver.net's password:
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 479 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
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 some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To diabliyo@git.miservidor.com:/home/git/data
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'diabliyo@git.miservidor.com:/home/git/data'

Y finalmente, en mi Servidor Local, tengo el archivo dedicado.txt, pero en el Servidor Dedicado las cosas estan intactas, vaya, no esta subido el archivo local.txt.

Alguna idea ?


« Última modificación: 11 Enero 2011, 04:06 am por Diabliyo » En línea

Foxy Rider


Desconectado Desconectado

Mensajes: 2.407


Deprecated


Ver Perfil WWW
Re: Git en GNU/Linux tengo problemas y dudas :(
« Respuesta #2 en: 12 Enero 2011, 14:37 pm »

Me parece que te salteaste algo ;)
Mirate este tutorial y el mensaje de error .. seguro que te salta la ficha de qué es : http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux

Saludos.
En línea

Diabliyo


Desconectado Desconectado

Mensajes: 1.441


shell# _


Ver Perfil WWW
Re: Git en GNU/Linux tengo problemas y dudas :(
« Respuesta #3 en: 13 Enero 2011, 18:07 pm »

Ya vi el tuto y sigo sin conseguirlo, ademas ese tuto no menciona nada interesante mas que laparte de hacer este config:

git config branch.master.remote origin && git config branch.master.merge refs/heads/master

Pero el config que no le veo razon es este: git config branch.master.remote origin, ya que estaria casando el branch.master.remote con el "origin", y en lo particular, no pienso trabajar con un solo repo, tengo varios proyectos ya finalizados y que hago updates esporadicamente, asi que yo declararia un git add remote NOMBREPROYECTO http://git.miservidor.com:/home/git/NOMBREPROYECTO.

Bueno, el problema continua, y por cierto, si en el Servidor Dedicado hago: git --bare init, no me crea el directorio .git/, me pone todo en el directorio raiz (donde teclee el comando), y despues cuando en el Servidor Local hago: git push diabliyo@git.miservidor.com:/home/git/PROYECTO, me dice:

Código:
fatal: Couldn't find remote ref HEAD
fatal: The remote end hung up unexpectedly
En línea

Diabliyo


Desconectado Desconectado

Mensajes: 1.441


shell# _


Ver Perfil WWW
Re: Git en GNU/Linux tengo problemas y dudas :(
« Respuesta #4 en: 14 Enero 2011, 00:33 am »

Ya pude subir mis actualizaciones :D, pero.... no se va al branch master.

Quizas el problema es que el branch master no tiene permisos para que los remotos lo actualicen...

Pero mi solucion de momento fue entrar al servidor dedicado, crear un branch X y dejarlo existente para que cuando un Remoto suba actualizaciones, utilice ese branch, el unico [/b]problema[/b] con esta modalidad, es que el master nunca se actualiza, es necesario entrar al Servidor Dedicado (por SSH) y actaulizarlo (git merge X).

El proceso fue:

Servidor Dedicado
Código:
shell# cd /home/git/
shell# mkdir proyecto  // creamos proyecto
shell# git init  //inicializamos SIN utilizar "--bare"
shell# git branch  // vemos los branch, solo tenemos a master
* master

// creamos el branch "dev" que usare para actualizar
shell# git branch dev
shell# git branch
* master
dev

En el Servidor Local (mi equipo)
Código:
shell# /home/miusuario/codigos/
shell# mkdir proyecto
shell# cd proyecto
shell# git init
shell# echo "prueba de texto" > hola.txt
shell# git add .
shell# git commit -am "estoy en Srv Local"

// subiendo al repositorio Servidor Dedicado
shell# git push diabliyo@git.miservidor.com:/home/git/proyecto dev

Ahora ya tenemos todo UP en el Servidor Dedicado, el problema es que solo se refleja cuando entras al branch dev, y para que master lo refleje, es necesario entrar y emerger.

Código:
// estoy en servidor Dedicado
shell# cd /home/git/proyecto
shell# git branch
* master
dev

// estoy hara que el branch "dev" actualize al branch "master"
shell# git merge dev

Y listo....

Agradeceria quien me dijera como hacerle para poder subir las cosas directo al branch master, porque si lo intento, me dice este error:

Código:
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 479 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
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 some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To diabliyo@git.miservidor.com:/home/git/data
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'diabliyo@git.miservidor.com:/home/git/data'
En línea

Foxy Rider


Desconectado Desconectado

Mensajes: 2.407


Deprecated


Ver Perfil WWW
Re: Git en GNU/Linux tengo problemas y dudas :(
« Respuesta #5 en: 14 Enero 2011, 23:58 pm »

Ahí te comenta que salvo que inicializes con --bare (por eso el link), no podés hacer un push master->master sin que pueda quedar inconsistente el tree, por eso el hacer un push a otro branch ...

Pero si insistís en hacerlo master->master simplemente logueate en el server remoto, andá a la carpeta donde está el repo y hacé un
Código
  1. git config receive.denyCurrentBranch ignore
pero por cada push, en el servidor va a corresponder un ( o poné un hook post-receive para no hacerlo a mano)
Código
  1. git reset --hard

digamos que, en limpio (para no perderse) ,toda la secuencia completa en el servidor quedaría así :

Código
  1. mkdir test.git
  2. cd test.git
  3. git init
  4. echo "Contenido de Prueba" >  a.txt
  5. git add a.txt
  6. git commit -sm "Initial Commit"
  7. touch .git/git-daemon-export-ok # para permitir que el repo se exporte
  8. git config receive.denyCurrentBranch warn # o ignore si no te interesa ver warnings
  9. touch .git/hooks/post-receive
  10. chmod +rx .git/hooks/post-receive
  11. nano .git/hooks/post-receive
  12.  
y ahí poné
Código
  1. #!/bin/sh
  2. cd ..
  3. env -i git reset --hard
  4.  

y listo ... you're done =P
ahora podés hacer push master->master sin ese error ...

Saludos.
« Última modificación: 15 Enero 2011, 00:01 am por vertex@Symphony » En línea

Diabliyo


Desconectado Desconectado

Mensajes: 1.441


shell# _


Ver Perfil WWW
Re: Git en GNU/Linux tengo problemas y dudas :(
« Respuesta #6 en: 9 Noviembre 2011, 19:37 pm »

Gracias [Alex] tus recomendaciones han resuelto el problema... PEro como bien dijiste, si hacemos el repo usando el comando git --bare init, no necesitariamos hacer las correcciones que me mencionaste...

Ahorita tengo un inconveniente, espero puedan ayudarem !...

Tengo un repo ya funcionando y todo, pero debido a que no tengo ya tiempo de estar tipeando en consola hacerle push de mis actualizaciones, me estoy intentando hacer un script para que lo ejecute cron cada ma~ana antes de llegar al trabajo, pero me topo con el problema que no logro meter el password :(....

Este es mi script:

Código:
cd /home/user/mi_proyecto/
git push miusuario@localhost:/mnt/respaldos/git/mi_proyecto master

Pero como han de saber, si ejecuto el segundo comando (de los que puse arriba), me pide password para autentificar y después hacer push... Y obviamente, si CRON ejecuta el script no puede meter el password, por lo cual, JAMAS se actualiza el repo...

Alguna idea ?

Saludos !
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines