2

I have a big project on bitbucket.org which is around 2GB. For some reason, git clone command breaks in between. So I decided to download the source files in a zip version provided by bitbucket.

Now what I want to do is that whatever changes I made to these files, I want to upload them to the Git repo over bitbucket.

Here is what I just tried:

  1. I extracted all files from zip to a folder "myproject"

  2. Then I run a below command git commands in this folder

git init

git add .

git commit -m "test commit"

so this step initialized a local git repository for me for those downloaded files.

  1. Then I run the below command to set up the remote repository

git add origin https://xyz@bitbucket.org/myproject/myproject.git

  1. Now I type below command to push the changes to remote repository

git push origin master

This all runs fine but the problem is in the last step, it uploads the whole project to remote repo in place of uploading just the files that were updated.

How do I fix this so that it can upload only the files that are changed?

osowskit
  • 5,904
  • 2
  • 29
  • 38
aslamdoctor
  • 3,753
  • 11
  • 53
  • 95
  • Can you please try a git pull first after you added the origin? Maybe you folder structure isn't exactly the same, or you are in the wrong directory. If git pull will download the repository, you have got something wrong. – Larce Apr 21 '17 at 11:01
  • Yes I just did the git pull few minutes ago, it is still running which means it's downloading full source code again? In that case, I hope it doesn't break in between. – aslamdoctor Apr 21 '17 at 11:03
  • So it is just replacing the files? Can you maybe try add -A instead of add .? - Or maybe it will just go trough with the pull. – Larce Apr 21 '17 at 11:04
  • isn't that same? here is difference http://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add – aslamdoctor Apr 21 '17 at 11:04
  • You can't modify the existing repo without first cloning it. – 1615903 Apr 21 '17 at 11:29

1 Answers1

0

The direct answer is you can’t only upload (push) the changed files and it’s not the way git works.

A git commit only calculate the changes of files and then use checksume as SHA_1 value.

the commit records the snapshot you set up in your staging area. Anything you didn’t stage is still sitting there modified; you can do another commit to add it to your history. Every time you perform a commit, you’re recording a snapshot of your project that you can revert to or compare to later

So the unchanged files has tiny effect for the size of a git repo. If you want to make the huge repo slim, you should find some fat commits in commit histories, and then find the biggest file and remove them in all commit histories. More details you can refer removing objects part in this chapter.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74