[英]Jenkins: How to checkout only new files and modified files when creating new branch
I am using Multibranch pipeline in Jenkins. I've some pretty large project - When creating a new branch, I'd like the git plugin to only checkout new files or changed files compared to a branch我在 Jenkins 中使用多分支管道。我有一些相当大的项目 - 创建新分支时,我希望 git 插件仅检出新文件或与分支相比更改的文件
Is there a way to do that?有没有办法做到这一点? I know once the branch exist, as long as I don't clean the workspace, it will just checkout new files and updated one, but what about new branches?
我知道一旦分支存在,只要我不清理工作区,它就会签出新文件并更新文件,但是新分支呢?
Say you have two branches, 'old-branch' and 'new-branch', both of which are synced with the remote.假设您有两个分支,“old-branch”和“new-branch”,它们都与远程同步。
git checkout old-branch
# Create a local branch called "new-branch"
# WARNING! Could blow away commits if you added them to to an existing local branch called "new-branch"
git switch -C new-branch
# Set the branch's HEAD without doing a checkout
git reset --soft origin/new-branch
# Un-stage staged changes
git reset
The repo's working copy of its files will be what they were before we started.回购文件的工作副本将是我们开始之前的文件。 Run
git status
to see differences.运行
git status
以查看差异。
new-branch
it'll show up as deleted
.new-branch
,它将显示为deleted
。new-branch
, it'll show up as untracked.new-branch
中被删除,它将显示为未跟踪。 If you then run:如果你然后运行:
git checkout .
This will undo all the modifications, and restore all the "deleted" (according to git) files, but importantly will not remove the untracked files .这将撤消所有修改,并恢复所有“已删除”(根据 git)文件,但重要的是不会删除未跟踪的文件。 This accomplishes what your original question states.
这完成了您最初的问题所述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.