I've a branch titled uat
on git.
I want to get a clone of all the files which are updated in merge
in the uat
branch.
(Basically idea behind it is to create a build to upload on uat server) .
I've tried doing this.
#!/bin/bash
branch=$(git symbolic-ref HEAD | sed -e "s/^refs\/heads\///");
if [ "uat" == "$branch" ]; then
// to do
// 1. get all updated files
// 2. create a clone of these files
fi
Can someone please help me with setp 1
ie get all the file updated in current merge.
如果刚刚发生合并(在合并后的钩子中应该是这种情况),您可以使用ORIG_HEAD
:
git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD
For a complete solution. Here is how to create a build with git
post-merge
hook
.
#!/bin/bash
# get current branch
branch=$(git symbolic-ref HEAD | sed -e "s/^refs\/heads\///");
# check if branch name is `uat` (or whatever you prefer)
if [ "uat" == "$branch" ]; then
# create a folder outside the git repo
# you can skip this step, if you want a static location
mkdir -p $(pwd)/../uat/$(basename $(git root));
# getting updated files, and
# copy (and overwrite forcefully) in exact directory structure as in git repo
yes | cp --parents -rf $(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD) $(pwd)/../uat/$(basename $(git root))/;
fi
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.