title: How can I automate git rebase and merge in a happy-path scenario?
body: <h3>Question</h3>
  
  <p>How can I automate the following steps with an intelligent script?  </p>
  
  <ol>
  <li>How do I programmatically detect if my <code>develop</code> is fast-forwardable to <code>origin develop</code>?  </li>
  <li>How do I programmatically detect if there are conflicts or not after doing <code>git rebase develop</code>?  </li>
  </ol>
  
  <h3>Partial Progress</h3>
  
  <ol>
  <li>I have figured out how to get current branch name with this script below with a <code>grep</code> and <code>sed</code>.<br>
  <code>my_curr_branch_name=$(git branch | grep '\*' | sed 's/^* //');echo "My branch name is $my_curr_branch_name"</code>  </li>
  <li>This is my work in progress for figuring out whether I am behind or up-to-date with the origin.<br>
   I haven't fully gotten it working fully yet.
   <code>git status | grep 'Your branch is behind'</code><br>
   and
   <code>git status | grep 'Your branch is up-to-date'</code><br>
   to figure out if I am behind or not.</li>
  </ol>
  
  <h3>My Git Merge Process</h3>
  
  <p>Lets say I am on <code>feature/long-feature-name</code> branch in my git repository.</p>
  
  <ol>
  <li><code>git checkout develop</code></li>
  <li><code>git fetch</code></li>
  <li><p><code>git status</code> (<strong>IF</strong> <code>develop</code> is behind <code>origin</code> <strong>and fast-forwardable</strong>, continue. Stop otherwise.)<br>
  <strong>EXPLANATION:</strong> This step is executed <strong>for myself</strong> to see if it is fast-forwardable.<br>
  <strong>QUESTION:</strong> How do I programmatically detect if my <code>develop</code> is fast-forwardable to <code>origin develop</code>?  </p></li>
  <li><p><code>git pull</code><br>
  <strong>EXPLANATION:</strong> I do <code>git pull</code> since I know I can safely fast-forward.</p></li>
  <li><p><code>git checkout feature/long-feature-name</code></p></li>
  <li><code>git rebase develop</code> (<strong>IF</strong> no rebase conflicts continue. Otherwise, stop.)<br>
  <strong>QUESTION:</strong> How do I programmatically detect if there are conflicts or not after doing <code>git rebase develop</code>?  </li>
  <li><code>git checkout develop</code></li>
  <li><code>git merge feature/long-feature-name</code></li>
  <li><code>git push origin</code></li>
  </ol>
  
  <hr>
  
  <h3>Functionality</h3>
  
  <ol>
  <li><p>The script needs to know which feature branch to go back to.</p>
  
  <ul>
  <li>When the script starts running at <strong>step #1</strong>, it needs to remember which feature branch I am on at that point, so it can <code>git checkout feature/{branch-name}</code> on <strong>step #5</strong> and <strong>step #8</strong>.</li>
  </ul></li>
  <li><p>The script needs to be smart to stop on the following conditions.</p>
  
  <ul>
  <li>after <strong>step #3</strong> if my <code>develop</code> is not fast-forwardable.</li>
  <li>after <strong>step #6</strong> if there are rebase conflicts.</li>
  </ul></li>
  </ol>
  
  <hr>
  
  <h3><code>git flow feature finish</code></h3>
  
  <p>I know <code>git flow feature finish</code> can do this, but not how I want it.<br>
  I don't want git flow script to <code>git merge --no-ff</code> which creates a merge point.</p>