How to link existing local source with NO local git repo to a remote git repo
Kind of a long story, but here’s the deal:
a repo that I downloaded the source code from (just via a zip, not by cloning it)
a fork of that repo that I was going to push changes to.
on my local machine, I unzipped the master repo’s source code that I downloaded and did some work on it.
Now, I’m in the situation where I want to push these changes back to the remote forked repo, but since I didn’t set up the repo locally when I first got the source code, I’m not sure what to do.
4 Solutions collect form web for “How to link existing local source with NO local git repo to a remote git repo”
Clone the repo the proper way.
From the cloned repo, do:
GIT_WORK_TREE=../test.wd git commit -am "Commit from work tree"
( you will have to add files if you have added new one:
GIT_WORK_TREE=../test.wd git add )
../test.wd is the path to the working directory where you had unzipped and done your changes
git push origin master
Alternatively, you can just copy files over to the clone and commit and push.
- clone the project (in another directory than your zip extracted directory)
- copy the contents of the zip extracted directory (with your modifications)
- paste it over the contents of the cloned project
- commit the changes
- push to remote
If your changes are relatively minor, just checkout the remote repo into a local repo, then apply your changes on top of it as a single commit, or over a series of reasonably-demarcated commits if necessary.
Simply add the remote repo as origin
git remote add origin <repo url taken from github>
I am unsure if that sets everything up the way that git does from the beginning but it should be sufficient to be able to push