![](/img/trans.png)
[英]How to delete commit messages in GIT without losing any changes in local repository and push the same to remote repository?
[英]How to import a git repository as a subdirectory of another git repository without losing any commit?
我有兩個 GitHub 存儲庫TinyDroids
和Miwok
TinyDroids
有一個子目錄JustJava
和一個README.md
。 這在日志中有大約 10 次提交。 Miwok
在日志中有大約 12 次提交。
如何將整個Miwok
存儲庫復制為TinyDroids
存儲庫的子目錄?
生成的TinyDroids
存儲庫必須有兩個子目錄: JustJava
和Miwok
。 此外,它必須具有原始的 10 次提交 + 來自Miwok
12 次提交。
到目前為止我嘗試過的:
git clone https://github.com/username/TinyDroids.git
cd TinyDroids
git clone https://github.com/username/Miwok.git
如果我在此之后提交並推送,則整個Miwok
子目錄將顯示為超過 10 個提交的單個提交。
我也試過:
git clone https://github.com/username/TinyDroids.git
cd TinyDroids
git pull --rebase https://github.com/username/Miwok.git
這在變基中產生了一些我不明白的問題。 此后的git log
僅顯示Miwok
的 12 次提交。
我建議創建一個分支並合並。 您可能還需要將Miwok
目錄移動到所需的子目錄。 這是要做什么的粗略草圖:
$ git clone https://github.com/username/TinyDroids.git
$ cd TinyDroids
# Create an orphan branch to pull the Miwok repo to
$ git checkout --orphan miwok
$ git pull https://github.com/username/Miwok.git
# Move the Miwok repo into a subdir
$ mkdir Miwok
$ git mv . Miwok
$ git commit -m "Move Miwok repo to Miwok subdir"
# Merge Miwok into TinyDroids
$ git checkout master
$ git merge miwok
命令git mv . Miwok
git mv . Miwok
不能正常工作。 這個想法是將所有內容移動到Miwok
子目錄。 您可能需要執行更多命令來手動執行此操作。
ps 由於這些是 Android Studio 項目,如果您希望它們成為單個項目中的模塊而不是兩個單獨的項目,則需要進行一些清理工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.