Git:如何在现有的回购中设置远程 [英] Git: how to set remote in existing repo
问题描述
我有一个关于git与不同分支的项目:
Master
Pre
Dev
....
我通过FTP在另一台服务器上安装了我的项目文件(不是通过git pull或git clone )以创建开发环境。
dev环境下的项目文件夹没有git repo。我可以设置这个文件夹是一个现有的回购(开发分支),而不做一个git pull或git克隆?
转到你的项目文件夹。添加远程 origin
与您现有的存储库URL。
$ git init
$ git remote add origin< existing-repo-url>
$ git checkout -b dev#checkout一个新分支'dev'
您需要在 master 之前存储(清理工作树并保存更改临时框)您的更改。 Stash 更改和 Pull
master
分支更改/提交。
$ git add。
$ git stash save'local changes'
$ git pull origin master#将'master'拖入'dev'分支
现在,从存储中检索/弹出本地更改。
$ git stash apply#返回清理前的代码
$ git commit -m'message'
$ git push -u origin HEAD#push to remote'dev'branch
一旦一切正常,请清理存储(可选)。
$ git stash drop
One question please
I have a project on git with differents branches:
Master Pre Dev ....
I've installed my project files in another server by FTP (not by git pull or git clone) ir order to create a dev enviroment.
The folder of the project in dev enviroment don't have a git repo. Can I set that this folder is a existing repo (dev branch) without do a git pull or git clone?
Go to your project folder. Add a remote origin
with your existing repository URL.
$ git init
$ git remote add origin <existing-repo-url>
$ git checkout -b dev # checkout a new branch 'dev'
You need to stash (clean working tree and save changes temporary box) your changes before pull the master
. Stash the changes and Pull master
branch changes/commits.
$ git add .
$ git stash save 'local changes'
$ git pull origin master # pull 'master' into 'dev' branch
Now, retrieve/pop local changes from stash.
$ git stash apply # return the code that cleaned before
$ git commit -m 'message'
$ git push -u origin HEAD # push to remote 'dev' branch
Once all is ok then, clean the stash (optional).
$ git stash drop
这篇关于Git:如何在现有的回购中设置远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!