Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7058211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:05:08+00:00 2026-05-28T04:05:08+00:00

Can I perform ‘merge’ that updates only existing files in current branch? For example,

  • 0

Can I perform ‘merge’ that updates only existing files in current branch?

For example, I have branch1: /file1, /x/file2, /file3. And branch2: /file1, /x/file2, /z/file4. I want to update files file1 and file2 in second branch with files from first.

As a solution I see creating separate commits in branch1 for that files, and than use chery-pick in second branch.

UPD:
Thanks to @fge, I’ve founded that solution (not so simple as I had expected):

git co branch2
git co branch1 -- ./
git reset ./
git ci -a
git clean -f
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:05:09+00:00Added an answer on May 28, 2026 at 4:05 am

    You can proceed as such while on branch2:

    git checkout branch1 -- file1 x/file2
    

    Then git add the modified files and commit the result.

    If you want to have the commit message of branch1 as well, you could commit with git commit -c branch1.

    Note that branch1 really is a refspec. A branch in git is nothing but a commit, but as a commit has links to its parent(s), it is, in effect, a “branch”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MDI WinForms application that can perform several tasks. Each task is
Let's say you have a business logic method that can perform some operation across
I have a computationally intensive task that users can perform using a Silverlight app.
I have a little library that can perform methods on a specific DOM element.
can anyone suggest me a plugin/tool that can perform a code formatting at build
Let's assume that our system can perform actions, and that an action requires some
I've written a small console application that can perform certain tasks. The user interface
What I want is a controller that can perform all operations on a table
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I need to know what language it returns, so that I can perform my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.