Fetching only files in the diff branch

I have a Bitbucket account.

I created a branch and want to upload ONLY the files in that branch.

If I go to Bitbucket and click on a branch, then click Diff ... I see a long list of files that I have edited, but I cannot just upload them.

If I upload files, upload a branch, this obviously gives me the whole project (not just the files changed in the branch)

Any ideas?

The reason why I want to do this

is that I found that if I use git and have these branches ... The files are either on my local machine or in Bitbucket ...

The moment I am happy with the branch version, I need to upload new files to our server.

It would be great to only have these files, because then I can just bundle them in filezilla and upload it to our server.

Other Notes

I am currently in my dev branch in the same repository for a project and I can just upload every file in that branch to my server. But since it loads so slowly to the server (20 minutes), it would be nice to just download the affected files instead ... to speed things up.

Related questions:

+3


source to share


1 answer


If you already have a cloned repository, you can export these files from that local repository and not from bitbucket if I understand your question correctly, which will also solve your problem as the slow part is uploading these files to another server.
To export the files you want, you need the first commit ID of your current branch, and then you can use diff-tree to list the affected files, and then tar commands to export them:

git diff-tree -r --no-commit-id --name-only --diff-filter=ACM
      "firstCommitOfTheBranch"..HEAD | xargs tar -rf exportedFiles.tar

      

The - diff-filter option allows you to select the type of files you want to view ([A] dded, [C] opied and [M] in this case), so if you want to make sure all modifications are included in the tar file, you you need to check if there are any files deleted or renamed:



git diff-tree -r --no-commit-id --name-only --diff-filter=DR
      "firstCommitOfTheBranch"..HEAD 

      

If the previous command returns some filenames, you will need to manually rename or delete them on your server.

0


source







All Articles