3

I have an account in Bitbucket.

I have made a branch and want to download ONLY the files in that branch.

If I goto Bitbucket and click on the branch, then click Diff... I can see the long list of files I have edited but cannot just download them.

If I goto Downloads then download the branch, it obviously gives me the whole project (not just the files modified within the branch)

Any ideas?

The reason I want to be able to do this

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

At the point when i'm happy with a branch version, I need to upload the new file changes to our server.

It would be lovely to have just these files because then I can simply sling them into filezilla and it upload to our server.

Other notes

I am on my dev branch at the moment under the one repository for a project, and I could just upload every file in that branch to my server. But because it's so slow to upload to the server (20 minutes), it would be nice to just upload the affected files instead... to speed things up.

Related questions:

Community
  • 1
  • 1
Jimmyt1988
  • 20,466
  • 41
  • 133
  • 233

1 Answers1

0

If you already have the repository cloned locally, you could export these files from this local repository instead of from bitbucket, if I understood your question correctly that would solve your problem as well, as the slow part is to upload these files to a different server.
To export the desired files you need the first commit id of your current branch and then you could use diff-tree to list the affected files and then the tar command 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 lets you choose the type of files you want to list ([A]dded, [C]opied and [M]odified in this case), so if you want to make sure that all the modifications are included in the tar file, you need to check that there are no files deleted or renamed:

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

If the previous command returns some file names, you would need to manually rename or delete them in your server.

Juan
  • 1,754
  • 1
  • 14
  • 22