2017-09-07 28 views
0

我一直在試圖使用git包命令導出我的本地git存儲庫。但看起來並非所有東西都被導出。我如何正確導出我的本地git存儲庫?我讀過,我不應該解開捆綁包,但我應該克隆它。無法使用git包導出本地git存儲庫

PS C:\dev\repo\local-repo> git status 
On branch dev 
Your branch is up-to-date with 'origin/dev'. 
Changes not staged for commit: 
(use "git add <file>..." to update what will be committed) 
(use "git checkout -- <file>..." to discard changes in working directory) 

     modified: application/config/config.php 
     modified: application/controllers/Account.php 
     modified: application/controllers/Hook.php 
     modified: application/controllers/Test.php 
     modified: application/models/User.php 
     modified: application/views/backend/account/main.php 
     modified: application/views/backend/account/nav.php 
     modified: application/views/backend/referrals_table.php 

Untracked files: 
(use "git add <file>..." to include in what will be committed) 

     application/models/Permission.php 
     application/models/Referral.php 
     application/models/Resellercredit.php 
     application/models/Resellerpackage.php 
     application/models/Usergroup.php 
     application/views/backend/account/reseller_center.php 

no changes added to commit (use "git add" and/or "git commit -a") 

PS C:\dev\repo\local-repo> git branch 
* dev 
master 

PS C:\dev\repo\local-repo> git stash list 
[email protected]{0}: On dev: linux migration stash 

PS C:\dev\repo\local-repo> git bundle create ..\migrate.git --all 
Counting objects: 4249, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (1546/1546), done. 
Writing objects: 100% (4249/4249), 10.17 MiB | 0 bytes/s, done. 
Total 4249 (delta 2709), reused 4186 (delta 2680) 



PS C:\dev\repo> git clone migrate.git remote-repo 
Cloning into 'remote-repo'... 
Receiving objects: 100% (4249/4249), 10.17 MiB | 0 bytes/s, done. 
Resolving deltas: 100% (2709/2709), done. 

PS C:\dev\repo> cd .\remote-repo\ 
PS C:\dev\repo\remote-repo> git branch 
* dev 
PS C:\dev\repo\remote-repo> git stash 
No local changes to save 
PS C:\dev\repo\remote-repo> git stash list 
PS C:\dev\repo\remote-repo> 

我真的需要這個存儲,因爲它包含我未提交的文件。是否有其他的替代方案來導出我的整個本地存儲庫(包括未分類的更改)?我試圖將整個文件夾複製到另一臺機器上(另一個操作系統是確切的),但是當我運行git status時,更多文件顯示在「unstaged changes」下。

回答

0

創建包時,請添加參考號refs/stash。我的測試--all不起作用。所以我必須列出我需要的所有參考,包括refs/stash

從包中創建一個克隆並檢出分支(您的案例中的dev)後,可以運行git fetch ../migrate.git refs/stash;git stash apply FETCH_HEAD以檢索存儲的更改。然後你可以運行git stash重新創建隱藏,如果你想稍後應用它。

如果您有多個存款條目,例如[email protected]{0}[email protected]{1}除以git stash list,則可以爲每個存款條目製作一個標籤。並將它們全部添加到包中。將它們應用到新克隆中,然後重新創建存儲條目。

git tag stash0 [email protected]{0} 
git tag stash1 [email protected]{1} 
git bundle create ../migrate.git stash0 stash1 dev <other_refs> 
cd .. 
git clone migrate.git -- sample 
cd sample 
git checkout dev 
git stash apply stash0 
git stash 
git stash apply stash1 
git stash 
git tag -d stash0 stash1