[DG: Open Forum] GIT add question

Noah Botimer botimer at umich.edu
Mon Oct 15 12:25:56 PDT 2012


Git add stages the file content at that moment. It is not a soft reference to the filename.

Subsequent edits followed by a git status will show unstaged changes in the file. Multiple git adds works, but it is not really a protective workflow measure. Usually, this will be when you staged a file but realized you forgot something before commit.

The branch is the way to fly -- really one of the best things in git, being able to do a cheap, instant, on-demand branch (from wherever/whatever state) and push changes around.

So long as you are working in your local repo (branch, add, commit, add, commit, add, commit, but no push), you can do exactly what you want with a "squash". You can do this as part of the merge (e.g., checkout master, merge --squash, add ., commit), or through a rebase on the branch (interactive works nicely) with squashing followed by a merge [1].

Both are pretty nice.

Thanks,
-Noah

http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html

On Oct 15, 2012, at 3:05 PM, Charles Severance 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"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/openforum/attachments/20121015/76997b4c/attachment.html 


More information about the openforum mailing list