0

In my git master I have 2 branches as production and testing. I do all work with testing. at present example my production version is 5. my testing version is 20. now I would like to update the production version from testing version of 15.

for that, how can i select the testing version of 15 and copy or merge to production version of 5? ( if the new testing version commit as id of 6 in the production version that' fine )

if anything wrong here please excuse me.

I don't have any idea. please help me.

koninos
  • 4,969
  • 5
  • 28
  • 47
user2024080
  • 1
  • 14
  • 56
  • 96

4 Answers4

1

Use git cherry-pick and the SHA1 of the commit you want to copy.

koninos
  • 4,969
  • 5
  • 28
  • 47
1

I would suggest you checkout (git checkout) the testing branch at the specific commit for version 15. then create a temporary branch git checkout -b version15merge and merge git checkout production && git merge version15merge this stuff into your production branch.

ckruczek
  • 2,361
  • 2
  • 20
  • 23
0

If you want to copy single commits, use git cherry-pick.
If you want to merge all changes in testing up to 15, just use git merge 15 to merge over the changes to production.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • I am trying like this: but getting error : ` C:\Tutorials\try>git cherry-pick 3bdb71b https://github.com/3gwebtrain/color-palette.git fatal: Not a git repository (or any of the parent directories): .git` - any idea the wrong what i do here? – user2024080 May 09 '16 at 12:48
  • You cannot cherry pick from a remote URL. You have to add this repository as remote if you did not have already and fetch its changes, then you cherry-pick. Except you have some addon like `git-spindle` or `hub` where you can do things like that. – Vampire May 09 '16 at 13:01
0

Use git cherry-pick <commit-hash from the source branch > when your destination branch is checked out. In your case find the commit-hash of version 15 in testing branch and then checkout the master branch and run the below:

git cherry-pick <commit-hash of version 15 from testing branch> 
Aditya Singh
  • 15,810
  • 15
  • 45
  • 67
  • Getting error like this : ` C:\Tutorials\try\color-palette>git cherry-pick f487636 error: could not apply f487636... Update start.txt hint: after resolving the conflicts, mark the corrected paths hint: with 'git add ' or 'git rm ' hint: and commit the result with 'git commit'` – user2024080 May 09 '16 at 12:26
  • This means you have conflict in some file when trying to cherry-pick the changes. Resolve the conflicts and then `git add ` the files and commit it – Aditya Singh May 09 '16 at 12:35
  • so, both of the version need to check-out in local system? – user2024080 May 09 '16 at 12:42
  • No just open the files mentioned in conflict message, here the `start.txt` and resolve the conflict from testing branch and master branch. You can refer http://stackoverflow.com/q/161813/3878940 to know more abou resolving conflicts – Aditya Singh May 09 '16 at 12:45