I have a develop branch (say at commit c) which is many commits ahead of master (say at commit a). But I forgot to push my production code (say at commit b) to master or to a separate branch.
Is it possible to push/merge my production code (i.e an earlier commit in develop branch) into master?
a (master branch)
a b c (develop branch)
(Need this commit
merged to master)
Edit: I don't want all the commits from develop merged/pushed to master, which is easy. I just want code up to a previous commit (not the last commit) to be merged to master. I have this code in a test server.
The solution for your problem is simply to merge everything up to the commit b into master.
In your case the following command should to what you want to do:
git checkout develop
git rebase master # Always suggested to avoid unneeded merge c onflicts
git checkout master
git merge <commit-id of b>
The small script below allows you to create a kind of a sandbox to play a little bit around with this scenario
mkdir sandbox
cd sandbox
git init
touch a.txt
git add a.txt
git commit -m "Added a.txt" a.txt
git checkout -b develop
touch b.txt
git add b.txt
git commit -m "Added b.txt" b.txt
touch c.txt
git add c.txt
git commit -m "Added c.txt" c.txt
git rebase master
git checkout master