tags:

views:

139

answers:

4

I commit a few changes locally and then push to github using 'git push origin master'. It always pushes the complete code base (judging by the amount of data transferred).

I must be missing something simple.. should only push up the changed files..?

+1  A: 

If you're looking at the number of "objects" that Git sends up to the remote, then this may be misleading you. Git creates an object not only for every file in your commit, but also for every directory (tree), every commit, and every tag. If you're doing operations such as merges, you may also have somewhat more commits than you may expect.

How big is your repository? What numbers are you looking at to judge the amount of data?

Greg Hewgill
+1  A: 

Git versions whole file trees, and each commit points to a complete snapshot of a tree. Git then relies on compression for keeping the size of the repository down. So the data that needs to be transfered when you push are these snapshots, rather than diffs. In effect, Git asks the server what its newest commit is and then sends all the local commits in that branch that are built on top of that. The objects are probably compressed when they are transfered, but they are still snapshots.

That is at least my understanding.

Christian Vest Hansen
A: 

this might be a trivial answer, but I think the mistake I've been making is to "git add ." befor commiting changes.

if I "git add filename" and then commit when I "git push origin master" only this file is transfered to github.

Dom
It's harmless to use `git add` for a file that is already in the repository and hasn't changed - Git will recognise this and not actually do anything. However, if you have any *other* files (such as compiled `.obj` files) that get added with the `git add .`, then that could certainly explain the behaviour you have seen. It's a good idea to get into the habit of doing a `git status` frequently, to make sure your idea of what's changed and Git's idea actually match.
Greg Hewgill
+1  A: 

That is a mystery to me too. My colleague has found that creating tracking branches helps:

http://www.zorched.net/2008/04/14/start-a-new-branch-on-your-remote-git-repository/

EDIT I found that this happens when I don't pull before creating a remote branch. If I pull first, it sends barely anything.

Igor Zevaka