简体   繁体   中英

How to update a GitHub project downloaded as ZIP file?

I have downloaded an archive of some large GitHub repository using Download ZIP link. It contained just the source code, so it wasn't a clone or a git repo anymore. Then I made some changes in this code on my disk and now I want to update it using the code of HEAD revision from the original GitHub repo (which has changed since I downloaded the ZIP file). But it's a large repo, so I don't want to download all the files, but just the modified ones.

Should I git init a new repo in my existing source code folder, then git add . and git commit then git remote add origin https://github.com/someuser/someproject.git and git pull origin master ? Will this download only the modified files?

Will this download only the modified files?

No, Git always works with all the files of a repo. In your case, git pull against an almost empty repo (only one revision) would still fetch all the revisions.

It is really easier to simply clone the repo (even if it is a large one), and copy over your modification, git add , commit and push: that will push only the modified files.

From Git 1.9.0, you could consider a shallow clone (cloning only the last revision), since you now can push from said shallow clone.
See " How to git fetch efficiently from a shallow clone ".

It is easier to make a clone and commit/push your changes. If you do not know how to use Git see this:

http://try.github.io/levels/1/challenges/1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM