Home > Net >  How to pull specific commit from remote repo
How to pull specific commit from remote repo

Time:09-28

I have 2 repos in my local project:

1. remote        # this is my working area, where I want to push a commit from side_repo
2. side_repo     # this is remote repo, where I want to pull the commit from

I read the question, and try to repeat the steps:

git remote add side_repo <url_of_side_repo>   # add remote repo
git fetch --all                               # fetch all chanches from remote and side_repo
git checkout -b backport side_repo/master     # create new branch based on master of side_repo
git cherry-pick <hash_of_commit_in_side_repo> # pull the commit from side_repo/master

After that I got this message:

Auto-merging arch/riscv/include/asm/pgtable.h
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 2193 and retry the command.
On branch backport
Your branch is up to date with 'side_repo/master'.

You are currently cherry-picking commit cba43c31f14b.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

nothing added to commit but untracked files present (use "git add" to track)
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git cherry-pick --skip'

I checked if I got chanches, I need. And it is ok: now file arch/riscv/include/asm/pgtable.h is correct.

BUT, how do I push this changes to my remote repo into specific branch? I want to save all info about commit, I pulled through git cherry-pick. And, if it is possible, save the same hash of the commit like it is in side_repo.

I tried to do this:

git commit --allow-empty
<fix commit message>
git push -u origin develop

and got message

Branch 'develop' set up to track remote branch 'develop' from 'origin'.
Everything up-to-date

What am I doing wrong?

CodePudding user response:

Maybe you can try to do git push -f origin yourLocalBranch:yourRemoteBranch instead of git push -u origin develop :)

Best regards,

CodePudding user response:

git checkout -b backport side_repo/master

Means that you are checking out side_repo/master into a new branch called backport

But then you try to push a branch called develop. Since you had not check out develop you did not modify develop and there are no changes to push.

The pushing is not your only problem. You are trying to cherry pick a change from your side_repo when you have already checked out your side repo.

git remote add side_repo <url_of_side_repo>   # add remote repo
git fetch side_repo master                  # fetch changes from remote repo master branch
git checkout develop                          # make sure we are modifying develop
git cherry-pick <hash_of_commit_in_side_repo> # cherry-pick the commit from side_repo/master into develop
git push -u origin develop                    # push to remote develop branch
  • Related