我已经运行了一个脚本,它重命名了很多文件夹,我想 git 知道它们被重命名而不是被删除。该脚本是一个 CakePHP 升级脚本。(./Console/cake 全部升级)。
git status 显示它们已被删除和添加,这意味着我丢失了所有 git 历史记录。为了解决这个问题,我删除了旧文件夹并添加了新文件夹,但是仍然有一些文件没有被拾取。
受影响的文件/文件夹是:
test becomes Test
config becomes Config
models becomes Model
libs becomes Lib
vendors becomes Vendor
controllers becomes Controller
plugins becomes Plugin
views becomes View
这就是我所做的;
git rm -r --cached tests && git add -A Test
git rm -r --cached config && git add -A Config
git rm -r --cached models && git add -A Model
git rm -r --cached libs && git add -A Lib
#Views doesn't work too well
git rm -r --cached views
git add -A View
rm -r --cache controllers
git add -A Controller/
除了views文件夹之外,几乎所有东西都正常工作。这是一些输出。您可以看到一些已作为重命名被拾取,但很多被拾取为新文件。
有什么办法可以让 git 正确拾取它吗?
# new file: app/View/Clients/edit.ctp
# new file: app/View/Clients/index.ctp
# new file: app/View/Clients/show_spreadsheet.ctp
# renamed: app/views/clients/spreadsheet_url.ctp -> app/View/Clients/spreadsheet_url.ctp
# new file: app/View/Clients/view.ctp
# renamed: app/views/clients/view_spreadsheet_queue.ctp -> app/View/Clients/view_spreadsheet_queue.ctp
# new file: app/View/Contacts/add.ctp
# new file: app/View/Contacts/edit.ctp
# new file: app/View/Contacts/index.ctp
# new file: app/View/Contacts/view.ctp
# new file: app/View/Dashboard/index.ctp
# new file: app/View/Dashboard/phone_lookup.ctp
# new file: app/View/Dockets/index.ctp
# new file: app/View/Dockets/select_for_invoicing.ctp
# new file: app/View/Dockets/select_for_payment.ctp
# new file: app/View/Dockets/show_processed.ctp
# renamed: app/views/dockets/view_job_for_date.ctp -> app/View/Dockets/view_job_for_date.ctp
# new file: app/View/Elements/admin_crumb.ctp
# renamed: app/views/elements/buttons.ctp -> app/View/Elements/buttons.ctp
# renamed: app/views/elements/client_autocomplete.ctp -> app/View/Elements/client_autocomplete.ctp
# new file: app/View/Elements/clients/incompatibility.ctp
# renamed: app/views/elements/communication_log.ctp -> app/View/Elements/communication_log.ctp
# new file: app/View/Elements/count_header.ctp
# renamed: app/views/elements/csv.ctp -> app/View/Elements/csv.ctp
# new file: app/View/Elements/dashboard/equipment_list.ctp
# new file: app/View/Elements/dashboard/phone_lookup.ctp
...