Boost logo

Boost :

Subject: Re: [boost] [git] add or move directories - was Modular boost directory structure
From: Bjørn Roald (bjorn_at_[hidden])
Date: 2013-08-27 03:26:11


On 08/27/2013 02:15 AM, Edward Diener wrote:
> On 8/25/2013 11:57 PM, Dave Abrahams wrote:

>>> BTW I have not been able to figure out how to add and move directories
>>> using git in a local copy. Instead I have just done so using the OS
>>> and git seems to figure it out but I have a feeling I have lost git
>>> history in doing so.
>>
>> You did it right; Git simply infers the move information. Git records
>> snapshots and ancestry, and that's about it. Part of its philosophy is
>> to be a "stupid content tracker" at its core.
>
> Feels odd coming from SVN but if it just works its fine with me.

I often find that the odd thing in git for new users is the concept of
the index. It helps a-lot to spend a few minutes trying to grasp what
the index is and how it can help you. If you attempt to ignore the
index, as I feel many new git users do, it often lead to confusion with
various git tools. If you use the index actively it becomes a great
tool that help you in day to day work as it is intended to do.

So what is the index: Simplest way to think of it is a staging ground
between your files (working tree) and the next commit. Only the changes
you have staged in index will be committed next time you do commit. You
can move, add and remove files, whole directories, even individual
changes within files (hunks) in the index based on selected current
content in your working tree and the add and rm subcommands -- or any
number of other tools and GUI that are based on them.

Then when reading documentation, I think you should always pay attention
when it talks about the index or staging, caching or tracking content.
All these terms are related to the index. When I am using the following
commands I always have the index in mind either to understand or to operate:

git status
git add <path>
git add -u
git mv <source> <destination>
git mv <source> ... <destination directory>
git rm <file>...
git diff
git diff --cashed
git commit -a
git commit

Note that:

git add -u
git commit -a
git mv

are just convenience features that allow you to do things in fewer steps
than just using bare bone

git rm
git add
git commit

When you commit, it is the state of the content changes in the index
that matters, not the steps getting it into that state. E.g. there is
no record in index that you used git mv, so you may just as well have
done some OS mv combined with changing index with git add/rm.

--
Bjørn

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk