How to pull only certain files to feature branch from main / other branches?

Shricharana Bharadwaj
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!
July 5, 2023

Hi,

I'm new to bitbucket and completely new to git as well. So please bear with me here.

I have a branch which I've set up as release and many feature branches. One of these feature branches has only two files, where as the release branch has many more files.  (I'm using Sourcetree GUI )

After merging the feature branch for the first time, when I try to merge the feature branch after an update to its files it gives me a conflict. To resolve this, according to a tutorial video, I have to pull the release branch into feature branch in local. 

The problem is, when I do this, all the files in the release branch gets added to the local branch, so I delete these files from the local branch and only keep the 2 files. Then I resolve the conflict and push the changes. But, when I'm merging this to the release branch again (through a pull request) , some how in the pull request, the rest of the files (those I deleted in local) are set to be deleted with the merge. When I do merge it, it deletes those files from the release branch leaving only two files in it. 

Note that the release and feature branches are set up as different clones with different folder locations in local.

So how do I resolve this? I don't want the files unrelated to the feature branch in that branch. 

Thanks in advance for any help.

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2023

Hello @Shricharana Bharadwaj and welcome to the Community!

It seems that the issue is occurring because after pulling the changes from the release branch into the feature branch, you are deleting the files from the feature. When you merge the feature branch back to the release branch, git will consider the file deletions as "wanted" changes and will apply the same deletion to the release branch.

In order to just merge the changes from the feature branch to the release branch, while on the release branch, right-click on the feature branch in SourceTree and click "Merge feature into release branch". This will merge the changes from the feature branch to the release branch.

If there are any conflicts, SourceTree will prompt you to resolve them. Use a merge tool or manually resolve the conflicts in the affected files by doing the following:

  • Remove the change designations added by Git

  • Correct the content

  • Save the file

Commit the files with resolved conflicts and push the result to Bitbucket repository.

The following articles might also be of help : 

Thank you, @Shricharana Bharadwaj !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events