subbu
subbu

Reputation: 562

How can I merge files from one branch to another branch in git?

I am using forked repository of MainRepo.in my forked repository I have a branch name as Demo2.In this branch I have 2 files names are file1and file2.

Know I want to merge total files from Demo2 to mergeTesting.for that purpose,I created a new mergeTestingbranch.for this purpose I ran the following commands

 I/Github/MainRepo[master]> git branch mergeTesting
 I/Github/MainRepo[master]> git checkout mergeTesting
 I/Github/MainRepo[mergeTesting]> git fetch origin
 I/Github/MainRepo[mergeTesting]> git merge origin/Demo2
 I/Github/MainRepo[mergeTesting]>git push --set-upstream origin mergeTesting

successfully,merging was completed and also pushed to my forked repository.

Know I want to delete entire files from the mergeTestingbranch.for that purpose I ran the following command

     I/Github/MainRepo[mergeTesting]> git rm 
     I/Github/MainRepo[mergeTesting]> git push origin

successfully,deleting completed and pushed to my forked repository.

know, in my mergeTesting branch their is no files.

after sometime I want to merge files from Demo2 to mergeTesting.for that purpose I ran the following commands.

 I/Github/MainRepo[mergeTesting]> git fetch origin
 I/Github/MainRepo[mergeTesting]> git merge origin/Demo2

but know,it shows Already up-to-date,but If I ran the follwing command it doesn't shows any files.

 I/Github/MainRepo[mergeTesting]> ls

How can I merge files in second time.

can anyone help me?

Thank you.

Upvotes: 0

Views: 671

Answers (1)

Stephen C
Stephen C

Reputation: 718798

Without seeing the exact sequence of commands that you executed, it is a bit difficult to tell what you've done wrong.

However, it sounds to me like might have forgotten to "git checkout mergeTesting" before you started changing stuff. Or maybe your "push" didn't do anything.

I suggest that you repeat exactly the steps that you performed before, keeping a copy of the exact commands and the output. Then Edit this Question, and cut-and-paste the details into it.

Upvotes: 1

Related Questions