I want to use an open source project from Github repository in my project which is placed on Atlassian Stash. But I know that I have to do some change on that project in order to be usable in mine. Furthermore I do want to be able to add future patches of that GitHub repository to my project. I have cloned the code to my local computer using following command:
git clone http://github.com/...
after that I added that code to my stash using following command:
git remote set-url origin http://MY-LOCAL_STASH/...
git push origin master
after doing that just the code placed on the server and GitHub git trackers were removed by git itself. Does anyone have any solution for my problem?
When you set-url
the URL for the origin
remote, you removed the original location, which is that of the GitHub repository. In Git, you can have many remotes, and the default name for the one you cloned from is origin
.
You should add another remote (I usually call it upstream
) and point it to GitHub. To update the copy of the code in Stash, you'll pull from upstream
then push to origin
. Run this:
git remote add upstream http://github.com/...
git fetch upstream
(Substitute the URL of the repo you cloned from.) Now you can do this whenever you want to update:
git fetch upstream
git push origin upstream/master