开发者

Relink with a Github Repository on a New Machine

I set up a github repository a while ago: https://github.com/LiamBailey/TweetSlider, with code for a little jQuery script to pull recent tweets for a given user and display them in a slider. Now I have added a few new features, and also made it a jQuery plugin. The first version was called TweetSlider v1 and the second is called TweetSlider v2.1.

First question: What should i do to add this new version to github, overwrite the existing code with the new, or create a fork for the new version?

If I should create a fork I have found the documentation for that and can manage to do that, but if I am to overwrite, which is what I have assumed I should do, then I am in a spot of bother.

Since creating the repository I have changed computers, and no longer have access to the local version of the original repository. How can I reconnect the repository to a new local directory and delete the existing files? Once I know how to do 开发者_如何学JAVAthat I have found the documentation to recommit the new files.

I hope someone can help with this.


The number one rule is: Never develop anything without a version control system :)

I don't know how exactly did you develop the second version - do you have it under version control in Git repository? Did you based the second version on the top of commits of the first version?

However, you can add GitHub as a remote repository (which probably answers "How can I reconnect the repository to a new local directory") in case that local directory is existing Git repo (which you can establish with git init command).

git remote add origin git@github.com:LiamBailey/TweetSlider.git

And the organization of your repositories is up to you - it depends if the original version still makes sense to use, if the new version has some backwards compatibility breaks etc.

If you want to have them as separate repositories, go for it.

If you want to replace the old version with the new one in the same repository, you have to options:

Dirty way - "backup" the old version to some branch and make a commit with the new version in master.

git init
-- copy the new version to this directory--
git add .
git commit
git remote add origin git@github.com:LiamBailey/TweetSlider.git
git fetch origin
git checkout origin/master -b v1
git push origin v1
git checkout master
git push -f origin master

Clean way - clone the original repo and make logical steps you did while developing the second version - each of this steps should be a separate commit. At the end you should have the new version with a nice history of commits.

git clone git@github.com:LiamBailey/TweetSlider.git
cd TweetSlider
-- make changes to your source code --
git add .
git commit
-- repeat until you have the second version --
git push origin master
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜