Custom Search
Showing posts with label cherry-pick. Show all posts
Showing posts with label cherry-pick. Show all posts

Thursday, November 26, 2015

How to git cherry-pick fix conflicts and edit commit message

1)
* -e --> to edit commit message
$ git cherry-pick -e ffed960e08b1aa340e020decc7cb5a735e7185ce
error: could not apply ffed960... update to working version of contrail module
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add ' or 'git rm '
hint: and commit the result with 'git commit'

2)
$git diff
Fix conflict

3)
$ git add Puppetfile

4)
$ git status
On branch kilo_multinode_contv2
You are currently cherry-picking commit ffed960.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:

    modified:   Puppetfile
    modified:   manifests/neutron/contrail/fip_pool.pp

5)
$ git cherry-pick -e --continue
[kilo_multinode_contv2 ba0dd5a] [bode] update to working version of contrail module
 Author: Dan Bode
 2 files changed, 7 insertions(+), 2 deletions(-)

6)
abort cherry-pick which has conflict and not required.
$ git cherry-pick --abort



Monday, August 10, 2015

How to git cherry-pick commit from another/upstream repository

1)
Clone forked repo
#git clone https://github.com/JioCloud/contrail-third-party.git
#cd
contrail-third-party.git

2)
Check all existing branches
#git branch
  branch1
  branch2
* master

3)
Add upstream remote (upstream repo) and name it "upstream_remote"
#git remote add upstream_remote https://github.com/Juniper/contrail-third-party.git

4)
Check all remotes
#git remote -v
upstream_remote    https://github.com/Juniper/contrail-third-party (fetch)
upstream_remote    https://github.com/Juniper/contrail-third-party (push)
origin    https://github.com/JioCloud/contrail-third-party (fetch)
origin    https://github.com/JioCloud/contrail-third-party (push)

5)
Fetch the latest version of master (fetch all branches) from remote "upstream_remote"
#git fetch upstream_remote

6)
Goto the branch where you want to apply the commits.
$git checkout R1.10
* This "R1.10" branch is in "origin" remote

7)
cherry-pick the commit from newly added  upstream_remote and apply.
$git cherry-pick [commit-id]

* You can use $git log command to find the commit-id from upstream_remote branches.
* Example:
   $git log -n 5 upstream_remote/branch_name