---
# System prepended metadata

title: '[Git] stash 備份'
tags: [stash, Git]

---

# [Git] stash 備份
[TOC]

## 查看所在儲存庫的 stash 列表
```=sh
$git stash list
```
會呈現像下面這樣的內容
```=pgsql
stash@{0}: WIP on main: abc1234 Some commit message
stash@{1}: WIP on feature-branch: def5678 Another commit message
```

## 產生 stash0.patch 檔案，內容包含該 stash 的變更
在當前目錄下會產生 stash0.patch
```=sh
$git stash show -p stash@{0} > stash0.patch
```

## 將檔案 (stash0.patch) 複製到新電腦
把變更套用到工作目錄
```=sh
$git apply stash0.patch
```
手動執行，重新建立 stash
```=sh
$git stash push -m "從舊電腦轉移的 stash"
```