title: Jenkins pipeline: merge fails
body: <p>I am currently setting up my pipeline to make it so when any changes is commited to a branch, it will merge with the master if the build and tests pass. However, I get this error:  </p>
  
  <pre><code>[Build, test and deploy front] Running shell script
  + git merge origin/Develop
  error: merge is not possible because you have unmerged files.
  hint: Fix them up in the work tree, and then use 'git add/rm &lt;file&gt;'
  hint: as appropriate to mark resolution and make a commit.
  fatal: Exiting because of an unresolved conflict.
  </code></pre>
  
  <p>The message is pretty clear, it wont merge due to a merge conflict. However, the branch I am trying to merge into master is a fresh branch created from master - so there are no changes currently. I don't know what conflicts it is refering to.<br>
  Here is my pipeline:</p>
  
  <pre><code>pipeline {
  agent any
  
  // this tool will be used for all stages/steps except over-written
  tools {nodejs "newest node"}
  
  stages {
          stage('build') {
                  steps {
              sh 'cd frontend'
                      sh 'npm install'
              }
          }
      stage('test'){
          steps{
              echo 'Hello, JDK'
          }
      }
      stage('update master'){
          steps{
              sh 'git merge origin/Develop'
              sh 'git commit -am "Merged develop branch to master'
              sh "git push origin master"
          }
      }
  
      }
  }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is the code I use now</p>
  
  <pre><code>pipeline {
  agent any
  
  // this tool will be used for all stages/steps except over-written
  tools {nodejs "newest node"}
  
  stages {
          stage('build') {
  
                  steps {
              sh 'cd client'
                      sh 'npm install'
              }
          }
      stage('update master'){
              steps{
                  sh 'git add -A'
                  sh 'git reset --hard HEAD'
                  sh 'git merge origin/Develop'
                  sh 'git commit -m "Merged develop branch to master"'
                  sh "git push origin master"
              }
      }
  
      }
  }
  </code></pre>
  
  <p>This returns the error:</p>
  
  <pre><code>HEAD detached from 25e2038
  Untracked files:
       frontend/
  
  nothing added to commit but untracked files present
  </code></pre>
  
  <p>So the merge now seems successful, but the commit wont go through and throws error on untracked files. frontend does not exist in my github folder, but my previous code did 'cd frontend', so it seems to be a change there which I can't get rid of. Hard reset does not remove it.</p>
  
  <p><strong>EDIT 2</strong>
  by adding <code>git clean -ffd</code>, the frontend/ folder is now gone, but the build still fails.</p>
  
  <p><strong>ANSWER</strong>
  This is a working version of the code I wanted to do:</p>
  
  <pre><code>pipeline {
  agent any
  
  // this tool will be used for all stages/steps except over-written
  tools {nodejs "newest node"}
  
  stages {
          stage('build') {
  
                  steps {
                      sh 'npm install'
              }
          }
      stage('update master'){
              steps{
                  sh 'git add -A' 
              sh 'git commit --allow-empty -am "Merged developer branch into master"'
              sh 'git merge origin/Develop' 
              sh "git push origin HEAD:master"
              }
      }
  
      }
  }
  </code></pre>