简体   繁体   中英

Git: how to set remote in existing repo

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM