[DG: Open Forum] GIT add question

D. Stuart Freeman stuart.freeman at et.gatech.edu
Tue Oct 16 13:09:00 PDT 2012


One thing to note with the interactive rebase is that you need to not
specify any commits that have already been pushed even if you don't
squash or edit them in the rebase. The very act of rebasing will change
the sha1 of the commit because the datestamp is included in the data that
is used to compute the sha1. Other than that, rebase is one of my
favorite features in git because I'll find myself making a commit,
working on something else and committing it, then realizing I need to fix
up that first commit. Which is really easy to do with an interactive
rebase.

On Mon, Oct 15, 2012 at 02:30:00PM -0500, Zach A. Thomas wrote:
> 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"
> 
> _______________________________________________
> 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"

-- 
D. Stuart Freeman
Georgia Institute of Technology
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
Url : http://collab.sakaiproject.org/pipermail/openforum/attachments/20121016/4892185c/attachment.bin 


More information about the openforum mailing list