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
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.
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.
new-branch
it'll show up as deleted
.new-branch
, it'll show up as untracked.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 . This accomplishes what your original question states.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.