On Oct 1, 5:57 pm, David Doria <daviddo...@gmail.com> wrote:

> I cloned a repository, created an Experimental branch, then worked on
> two files:
>
> 1) edit a.h
> 2) edit b.h
> 3) git add .
> 4) git commit -m "worked on a and b"
>
> Now I have decided that a.h is ready to push into the main repository,
> but b.h is not. Is there a way to push only a.h even though the work
> on both files is combined together in a single commit?

No, there's no way to do this, but you should not think in terms of
files when working with Git.
Git works with snapshots of the entire tree (each commit is a snapshot
of the whole work tree).
Hence, if you have a commit which changes both files but you only want
to publish changes made to one of these files, you have to split this
commit (changeset) into two or more commits so that you have a commit
which contains only the changes made to one file (and another one with
changes to the other file). After this, you'll be able to push
specific commit to a respective remote branch.
To do this you can use different approaches.

If the commit representing changes to these files is single and is at
the tip (HEAD) of you branch, just do
$ git reset HEAD^
and then commit the changes one by one, making one (or more) commits.

If the changes span several commits you will have to use `git rebase`.

Now you will have a commit which represents changes to just one file
and you can use its name to update a relevant remote branch.

Note that the whole approach smells bad. I think you should consider
creating one or more branches to develop "unstable" features and one
"stable" branch into which you will merge the needed changes and which
you will push.

-- 
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