How to raise merge request only for specific files

Hi Team,
I have one issue like i have pushed many changes to my local repository . Let’s say file1,file2, file3 are pushed into local repository but i want to merge only file1 into remote repository . Is it possible to achieve ? If so, please provide the workaround to do by me.

Thanks, Dhruba.

Hi @swaindhruv89,

When you do a push, git only takes the changes that you have committed.
Just add that one file to staging and commit it.

Follow below steps to resolve the issue:

  1. git status
  2. git commit -m “Your message” {filename}
  3. git status
  4. git push origin master

If the branch you are on has been changed and pushed by someone else you’ll need to pull first. Then push your commits.

Regards,
Kiran

1 Like

@kirangavali’s answer is correct, but only of value if you haven’t already pushed.

You can only create merge requests between branches, so if the changes are mixed together on one branch it’s not simple.

The good way out of this is to get your local changes into a number of branches, and then push those seperately, and make a merge request from the branch containing the changes you want merged. I guess that can be done with a soft reset (to the upstream version) and some sequence of branch creation, branch checkout, add, commit and possibly stash. But it’s not something I can provide a detailed guide to, I feel it requires to much attention to the details.

1 Like

Hi @swaindhruv89!

When a person clones a repository on the local machine and make many changes in it, you can run the following command to see what all files are affected by the changes:

# git status

The user can run the command:
# git add <file-name>
to add the changes to the staging area. At this level the user can decide from a number of changes, changes to which file are to be committed. if all the changes are to be committed then the user can run “git add .”

After adding the changes to the staging area(using the add command), now when the user runs the command
# git commit -m "your message"
only the changes added to the staging area will be committed. In this way you can choose which changes you want to commit. And the changes which are committed are only pushed to the remote repository by running the following command:

# git push origin master

I hope this helps you out.

Cheerio!