Mryqu's Notes


  • 首页

  • 搜索
close

[Git] Create patch with untracked files using Git format-patch/diff/stash

时间: 2015-01-26   |   分类: Tool   Git     |   阅读: 205 字 ~1分钟

Setup testing environment

I created 123.txt at branch master, then modified 123.txt and added321.txt at branch yqu

C:\test>mkdir GitTest

C:\test>cd GitTest

C:\test\GitTest>git init
Initialized empty Git repository in C:/test/GitTest/.git/

C:\test\GitTest>echo "this is a file at mast branch" > 123.txt

C:\test\GitTest>git add 123.txt

C:\test\GitTest>git commit -m "initial commit"
[master (root-commit) f140825] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 123.txt

C:\test\GitTest>git push origin HEAD:master

C:\test\GitTest>git checkout -b yqu
Switched to a new branch 'yqu'

C:\test\GitTest>echo "bye" >> 123.txt

C:\test\GitTest>echo "this is new file at branch yqu" > 321.txt

Try patch-format

C:\test\GitTest>git format-patch master

patch-format command only works for committed files.

Try diff

[Git] Create patch with untracked files using Git format-patch/diff/stash “git diff” is used for unstaged changes, “gitdiff –cached” is used for staged changes, neither includeuntracked files.

Try stash

[Git] Create patch with untracked files using Git format-patch/diff/stashThe above “git stash” and “git show” commands can satisfy the requirement.

Solution

git stash show -p > patch
git show fd056bfee6b7129f916f81247f39a4d39d27b466 >>patch

Reference

How to create and apply a patch with Git
Create a git patch from the changes in the current working directory
Can I use git diff on untracked files?
In git, is there a way to show untracked stashed files without applying the stash?
Git stash to patch with untracked files
How to recover from “git stash save –all”?

标题:[Git] Create patch with untracked files using Git format-patch/diff/stash
作者:mryqu
声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!

#git# #patch# #format-patch# #diff# #stash#
[Git] Create patch with untracked files
[C] 了解printf中的%.s
  • 文章目录
  • 站点概览

Programmer & Architect

662 日志
27 分类
1472 标签
GitHub Twitter FB Page
    • Setup testing environment
    • Try patch-format
    • Try diff
    • Try stash
    • Solution
    • Reference
© 2009 - 2023 Mryqu's Notes
Powered by - Hugo v0.120.4
Theme by - NexT
0%