On Wed, Mar 31, 2010 at 2:08 PM, vfclists <vfcli...@googlemail.com> wrote:
>
>
> On Mar 31, 6:03 pm, Rick DeNatale <rick.denat...@gmail.com> wrote:
>> On Wed, Mar 31, 2010 at 12:11 PM, vfclists <vfcli...@googlemail.com> wrote:
>>
>> > On Mar 31, 4:20 pm, Rick DeNatale <rick.denat...@gmail.com> wrote:
>> >> Is this what you are looking for?
>>
>> >>http://www.gitready.com/beginner/2009/01/19/ignoring-files.html
>>
>> > Using .gitignore is something I have considered, but it looks like it
>> > is going to get more interesting than that.
>> > I will probably have to use separate directories, and use some kind of
>> > condititional excludes or includes if .gitignore supports something
>> > like that.
>>
>> > Does checking out a branch erase all the directories and files in the
>> > working directory and replace them with only the contents of the
>> > branch?
>>
>> Only files which are tracked will be affected by a checkout.
>>
>> Files don't get tracked until you git add them.
>>
>>  .gitignore is a way to keep new files from being tracked.
>>
>
> Does this mean that if you checkout a branch, only files that you add
> are committed, even if in the original branch they are still tracked?
> That will be a new discovery  for me if that is the way git works.

Okay, note I have gs as an alias for 'git status',  and gc as an alias
for 'git commit'

→ mkdir gitexample

→ cd gitexample

~/gitexample
→ git init
Initialized empty Git repository in /Users/rick/gitexample/.git/

~/gitexample [git:master]
→ gs
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)

~/gitexample [git:master]
→ echo "hello" > file1.txt

~/gitexample [git:master]
→ gs
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       file1.txt
nothing added to commit but untracked files present (use "git add" to track)

~/gitexample [git:master]

→ git add file1.txt

~/gitexample [git:master]
→ gs
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   file1.txt
#
~/gitexample [git:master]
→ gc -m'first commit'
[master (root-commit) 7997c23] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 file1.txt

~/gitexample [git:master]
→ gs
# On branch master
nothing to commit (working directory clean)


~/gitexample [git:master]
→ gs
# On branch master
nothing to commit (working directory clean)

~/gitexample [git:master]
→ echo " world" >> file1.txt

~/gitexample [git:master]
→ gs
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   file1.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

So even tracked files which are changed don't get commited unless you add them.

But there is an option (-a or --all) on git commit which will add
tracked files in the process of committing.  It's not uncommon to get
into the habit of using this, which is why .gitignore is useful since
git commit -a won't pick up files which are ignored.

There are also options to interactively determine at commit time which
files to commit, but I won't go into that here.
-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to