[Linux-Biella] hg vs git spiegatemi

Daniele Segato daniele.bilug a gmail.com
Ven 18 Nov 2011 16:08:01 CET


On Fri, 2011-11-18 at 15:19 +0100, PaulTT wrote:
> On 18/11/2011 13:41, Daniele Segato 說:
> > On Fri, 2011-11-18 at 12:52 +0100, PaulTT wrote:
> >> On 18/11/2011 12:05, Paolo Ciarrocchi 說:
> >>> 2011/11/18 Federico "Darkmagister" Pietta<f.pietta a gmail.com>:
> >>>> io naturalmente compilo il programma dopo il pull ...
> >>>> quindi creo la dir build ci vo dentro do un cmake ../ e poi compilo ...
> >>>>
> >>> ma prima di fare il pull fai un make clean e/o un git clean -dxf e/o
> >>> git reset --hard?
> >> ecco, perche' serve?
> >> se io non ho committato nulla, perche' dovrebbe farsi gli affari miei e
> >> rompere, a priori?
> > ma in realtà la domanda è: secondo te cosa dovrebbe fare?
> >
> > il pull è un'operazione di merge, tipicamente
> > quindi la semplice domanda è: cosa dovrebbe fare git, secondo te, nel
> > caso c)?
> uh, chiedermi cosa fare?
> oppure, altra domanda, esiste un --force che mi forzi l'update al 
> mainstream?
> senza dover _IO_ scrivere un clean inutile prima?
> 
> > e sinceramente vedo lo stesso problema per mercurial
> 
> hg pull -u senza --force mi fa il merge in automatico, se io ho una 
> modifica in locale e il remoto non e' cambiato
> cosa che detto tra noi, fa gia' anche svn eh ;P, o quantomeno chiede 
> direttamente


mastro a mastroc3 /tmp/test-git  $ git init --bare remote.git
Initialized empty Git repository in /tmp/test-git/remote.git/

mastro a mastroc3 /tmp/test-git  $ git clone remote.git developer
Cloning into developer...
done.
warning: You appear to have cloned an empty repository.

mastro a mastroc3 /tmp/test-git  $ cd developer/

mastro a mastroc3 /tmp/test-git/developer (master #) $ echo 'I will not
touch again this file' > untouched-file.txt

mastro a mastroc3 /tmp/test-git/developer (master #) $ echo 'I will modify
this file' > to-be-modified-file.txt

mastro a mastroc3 /tmp/test-git/developer (master #) $ git add .

mastro a mastroc3 /tmp/test-git/developer (master #) $ git commit -m
"initial commit"
[master (root-commit) bbd7d9d] initial commit
 2 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 to-be-modified-file.txt
 create mode 100644 untouched-file.txt

mastro a mastroc3 /tmp/test-git/developer (master) $ git push origin
master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 331 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
To /tmp/test-git/remote.git
 * [new branch]      master -> master

mastro a mastroc3 /tmp/test-git/developer (master) $ cd ..

mastro a mastroc3 /tmp/test-git  $ git clone remote.git ptt-clone
Cloning into ptt-clone...
done.

mastro a mastroc3 /tmp/test-git  $ cd ptt-clone/

mastro a mastroc3 /tmp/test-git/ptt-clone (master) $ ls
to-be-modified-file.txt  untouched-file.txt

mastro a mastroc3 /tmp/test-git/ptt-clone (master) $ echo 'local
modification' >> untouched-file.txt 

mastro a mastroc3 /tmp/test-git/ptt-clone (master *) $ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working
directory)
#
#	modified:   untouched-file.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

mastro a mastroc3 /tmp/test-git/ptt-clone (master *) $ cat
untouched-file.txt 
I will not touch again this file
local modification

mastro a mastroc3 /tmp/test-git/ptt-clone (master *) $ cd ../developer/

mastro a mastroc3 /tmp/test-git/developer (master) $ echo 'main stream
change' >> to-be-modified-file.txt 

mastro a mastroc3 /tmp/test-git/developer (master *) $ git commit -a -m
"main stream change"
[master fe6e4eb] main stream change
 1 files changed, 1 insertions(+), 0 deletions(-)

mastro a mastroc3 /tmp/test-git/developer (master) $ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 339 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /tmp/test-git/remote.git
   bbd7d9d..fe6e4eb  master -> master

mastro a mastroc3 /tmp/test-git/developer (master) $ cd ../ptt-clone/

mastro a mastroc3 /tmp/test-git/ptt-clone (master *) $ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working
directory)
#
#	modified:   untouched-file.txt
#
no changes added to commit (use "git add" and/or "git commit -a")


# qui....
mastro a mastroc3 /tmp/test-git/ptt-clone (master *) $ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.


Maggiori informazioni sulla lista Linux