Io chiaramente non capisco affatto git. Questo è quello che sto ottenendo:git staging e commit tra più rami
git branch (outputs that I'm on master)
git checkout -b foo
echo "next line" >> file (file is an existing file)
git add file (stages)
git checkout master
git status (shows that file has "next line" and is staged!!)
git commit (commits the changes that were staged on branch foo!!)
git checkout foo
Ecco il kicker. pippo ora non mostra alcuna modifica apportata al file nella directory di lavoro O messo in scena.
Quindi sembra che tutte le modifiche apportate, inclusi la modifica di file e la gestione temporanea, avvengano su TUTTI i rami. e quando si COMMIT su un ramo specifico, tali modifiche vengono scartate su tutti gli altri rami eccetto quello su cui si è effettuato il commit.
È questo che sta succedendo? Qualcuno può aver senso per me? Sembra un comportamento completamente fasullo e chiaramente non ho un'idea di design che renda questa cosa sensata.
Modifica per esempio esplicito:
$ mkdir element
$ cd element
$ git init
Initialized empty Git repository in /home/dan/element/.git/
$ echo "one" >> one
$ git add one
$ git commit -m msg
[master (root-commit) 36dc8b0] msg
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 one
$ git checkout -b fire
Switched to a new branch 'fire'
$ echo "next line" >> one
$ git checkout master
M one
Switched to branch 'master'
$ cat one
one
next line
$
che contraddice palesemente questo dal git pro libro:
This is an important point to remember: Git resets your working directory to look like the snapshot of the commit that the branch you check out points to. It adds, removes, and modifies files automatically to make sure your working copy is what the branch looked like on your last commit to it.
La mia risposta aiuta a chiarire le cose? Penso che sia antecedente alla tua modifica, ma non ne sono completamente sicuro. – larsks