Data Integrity & un-Commited Branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Just started using Git today and I already shot myself in the foot. I
found, when working within a newly created branch, you are allowed to
switch branches without committing. The un-commited changes will then
be present in all other branches. And committing any branch will
save/commit the present changes to that current branch. Here's how to
replicate the inconsistency.

Create an git repo, spawn a file, and commit
$ mkdir project; cd project; git init; echo "created" > test; git add
.; git commit -m "initial commit"

Create a demo branch, checkout, and edit the file
$ git branch demo; git checkout demo; echo "from demo" >> test; cat test

Switch to master and edit file
!!! The file was modified in demo, git should not allow this switch
without commiting!
$ git checkout master; echo "from master" >> test; cat test

Switch to demo, commit
$ git checkout demo; cat test; git commit -a -m "demo commit"
$ git checkout master; cat test

Once demo has a commit, an un-commited change in master will prevent
switching to demo
$ echo "from master 2" >> test; cat test; git checkout demo
> fatal: Entry 'test' not uptodate. Cannot merge.

-- 
Brian Scott Dobrovodsky
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux