Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to download file changes for specific commit?

Nishant Kathiriya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 28, 2018

for example, there are 100 files in my whole project. And I have modified only 10 of them and pushed it. Now I want to download only that 10 files with latest changes separately.

1 answer

1 vote
Rajath Veeramanchala September 30, 2018

Hi @Nishant Kathiriya,

Use this option to see only the files changed in the previous commit :

git diff --name-only HEAD HEAD^1

and you can create and archive of changed files using the below command :

git archive --output=latest_artifact.zip HEAD $(git diff --name-only HEAD HEAD^1) 

To make sure this runs correctly, You have to do the following :

1. Make sure your merge strategy is Merge commit - Usually makes a merge commit every time resulting in your latest commit having changes of all the commits from source branch to target branch.For example : 3 commits from feature to dev will add 4 commits to dev with the 4th commit being merge commit and having all changes of the first 3 commits.

2. Disable Automatic merging under Branching model - Merging master to dev automatically or release/* branches to dev

3. Run the command in script task after your source code checkout task

The only problem with the merge strategy being merge commit is that it will create a large commit history and with Automatic merging it can further mess up the commit history. Also you can`t have any .zip files in your repo and in bamboo you can create an artifact of the *.zip file and then use deployment project / SCP task to copy the zip file to server. 

Hope this helps. The version is 5.12 when I`m writing this answer. I have tested multiple scenarios using this method and it worked as expected. Let me know if you see any issues.

 

Regards,

Rajath

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events