I\'m using Git 1.7.4.1. I want to push commits I did on one folder to my remote repo. How do I push only changes from one folder to my remote repo? All the documentation
Git works by pushing entire commits. Either rebase interactively to isolate your changes to the directory you are interested in., or make a submodule for it.
Git is not like subversion. The short answer is, you can't.
You should consider rebasing your change (only the one relevant) against the remote
git rebase -i origin/trunk
should get you underway. Be sure to read the comments and instructions along the way. There is also man git-rebase
of course.
In the end, when you are satisfied with the result, you can either create a new branch from there
git checkout -b rebased HEAD
or you can opt to make it your new master. I'll leave it up to you how to manage your branches locally (because you didn't tell us about them).
Pushing woud then be easy with
git push origin trunk
git's unit of work is the commit. If you want to push changes to one directory but not others, those changes need to be separate commits.
If you haven't pushed these changes elsewhere yet, you can try an interactive rebase to make your commits look the way you need. See the git-rebase man page and this chapter in the Git community book for more details.
The error that you report is not reporting conflicts - you only get conflicts locally when merging (e.g. as part of a git pull
). That error is just refusing to update the remote branch with your commit, since your commit doesn't include the history of the branch you're trying to push to. Typically that means that someone else has pushed some divergent development to that branch and you need to pull or rebase - there's more on that here: How git works when two peers push changes to same remote simultaneously
However, to answer your question directly, commits always represent the complete state of the tree, so you just need to create a commit which only has the changes in the subdirectory of interest. Just change into that subdirectory and use git add
to stage the files that you've changed in there. Then, when you commit, make sure that you don't use the -a
parameter, otherwise all the changes in your repository will be introduced into that commit.