[DG: Open Forum] GIT add question

Zach A. Thomas zach.thomas at gmail.com
Mon Oct 15 12:30:00 PDT 2012


In git, steps 1 and 2 are typically combined, like this:
git checkout -b my-cool-new-feature

git rebase -i is also known as an interactive rebase. You can go down the list of commits and specify what you want to do with each one (pick, edit, squash).

Another way to do what you're talking about is to switch back to master and merge with the --squash option.

git checkout master
git merge --squash my-cool-new-feature

That will bring all the changes over from the other branch as staged-but-not-yet-committed. You can then perform a new commit with a description of all the changes you're making.

Zach
On Oct 15, 2012, at 2:14 PM, Dave Ross <dave.ross at gmail.com> wrote:

> To answer your first question, yes git add puts the content of that
> file *at that time* into the staging area. If you change it after
> that, it won't be part of the commit, unless you add those additional
> changes. This is really what allows partial commits in git (meaning
> you can have multiple changes in a file and spread them over several
> commits).
> 
> For packaging up a bunch of commits to make things cleaner to your
> "audience",  Git makes this easy - you can simply squash all the
> commits in your branch prior to merge.
> 
> See: http://ariejan.net/2011/07/05/git-squash-your-latests-commits-into-one
> 
> -Dave
> 
> On Mon, Oct 15, 2012 at 12:05 PM, Charles Severance <csev at umich.edu> wrote:
>> I have a question about "git add"
>> 
>> Does "git add" simply add a file to the list of things that will be included in a commit or does it add a particular version of the file to the staging area?
>> 
>> For example if I edited a file and then did a "git add" and then edited the file some more and then did a "git commit" - what would end up being committed?  Only the first edit (before the add) or would both edits end up in the commit?
>> 
>> One of the things I want to do is work one something kind of experimental and have version history that is pretty fine grained while I am fooling around but then when it is all done, I want to roll up all that history into one big commit.
>> 
>> So I think this is what I want to do
>> 
>> (1) make a branch
>> (2) switch to the branch
>> (3) hack to my heart's content committing as often as I like
>> 
>> Here is where it gets foggy.
>> 
>> I would like to take everything from my branch and pull it into master but collapse the 20+ commits to my breanch into one commit in the master so I have less to push around to other repos with my software.
>> 
>> Make sense?
>> 
>> /Chuck
>> _______________________________________________
>> openforum mailing list
>> openforum at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/openforum
>> 
>> TO UNSUBSCRIBE: send email to openforum-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
> _______________________________________________
> openforum mailing list
> openforum at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/openforum
> 
> TO UNSUBSCRIBE: send email to openforum-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"



More information about the openforum mailing list