git: import changes from non git repository

2019-05-29 02:27发布

问题:

Scenario:

  • Local git repo, default master branch
  • FTP server with content of the repo (non git), synchronized daily with the local repo, master branch

Workflow:

  • user1 is working on local git repo (git add, working directory clean)
  • user2 (non git user) changed files directly on the FTP server

How can I import all files changed on FTP to the local git repo and see what has changed?

回答1:

It sounds a bit nightmarish. I assume it is no option to have a git repository on the FTP server. In that case I would create a separate branch in my work repository:

git checkout -b ftp

copy the ftp stuff over and commit it to the branch:

git commit -a 

then go back to the master:

git checkout master

and do the normal merge, diff, cherry-pick from the FTP branch. You might want to delete the FTP directory after merging is done.



标签: git ftp merge