git merge untracked branch removes code

I am working with a team on git and my local untracked production branch is missing lines of code from a team member.

My local master branch is tracked on the remote/origin/master and it shows all the code.

The local production branch was checkedout from remote/origin/production with this command

git checkout production

After finishing the development branch I did:

git checkout production
git merge development

I deploy to server and then

git checkout master
git merge development
git merge production
git push origin master

Later I find out that production branch and server are missing some lines of code (while master is ok)

I thought this could be caused by the fact that the remote branch was not tracked with git checkout --track production

Then I found that git diff master..production does not show differences, but analyzing the production branch I can find this commit relative to the merge of the development branch:

git show b17832a
commit b17832ae656f1bd43ebf837934f16b7d1f6efa33
Merge: a9bd850 0873d56
Merge branch 'development'

and here I can find the removed line of code

git diff a9bd850..0873d56 file.rb
diff --git a/file.rb
index e0d1d1b..2343d92 100644
--- a/file.rb
+++ b/file.rb
@@ -49,12 +49,6 @@ angular.module('sp').directive 'spPlayer', [
some text and below I can find
- my missing line of code
- is showing here

how can I fix the production branch and push the change? My commit on master have already been push to the remote.



answered 6 days ago Sajib Khan #1

You mentioned:

Later I find out that production branch and server are missing some lines of code (while master is ok)

Update local production with master then push to remote production (origin/production).

$ git checkout production
$ git merge master
$ git push origin production

Update remote master (origin/master)

$ git checkout master
$ git push origin master

N.B. the issue is solved discussing in OP's comment section actually.

comments powered by Disqus