Git: how to set remote in existing repo

不羁岁月 提交于 2019-12-05 16:19:18

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!