I have a super slow connection right now, and I need to push a new branch into my company's git server. With SVN, I am able to commit/push files to a remote SVN server one at a time if I'd like. In the past, when I had a slow connection, I was able to upload a folder at a time and it worked great. I sure could use something similar in git.
-
Have you tried it? Git compresses everything (and so on), thus there is a good chance, that it will work on slow connections too. – KingCrunch Jun 24 '12 at 20:12
-
In addition to the answers below, depending on the protocols you're using, `git push` is pretty good at both compressing the transfer and working out the minimal amount of data to send to ensure synchronisation. – simont Jun 24 '12 at 21:24
2 Answers
When you do a git-push(1), the manual says:
The
<src>
is often the name of the branch you would want to push, but it can be any arbitrary "SHA-1 expression", such as master~4 or HEAD (see gitrevisions(7)).
As a result, you should be able to push individual commits up to the remote by organizing them in chronological order, and then specifying each one in a detailed refspec. For example:
# Get all commits not in remotes/origin/master and
# sort in chronological order.
commits_list=$(
git log --oneline --reverse refs/remotes/origin/master..HEAD |
awk '{print $1}'
)
# Push each commit one-by-one to origin/master.
for commit in $commits_list; do
git push origin $commit:refs/heads/master
done
I tested this locally, and it seems to work as intended. Give it a try; if nothing else, it will get you pointed in the right direction.

- 81,402
- 15
- 141
- 199
If your branch consists of many small commits adding up to one large change, you might be able to effect this by pushing the commits up in stages. Perhaps create a new branch starting at the point at which your code diverges from that on the company server, then pull ranges of commits from your branch in stages and push after each range is pulled.
But pushing separate folders/files - I'm pretty certain that's not possible: it rather goes against git's requirement that a commit be an atomic entity.

- 6,690
- 27
- 44