Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge a PR from command line using hub?

I'm using git / hub with github following a gitflow workflow in my project and I'm wondering if there's a simple way to avoid entering github to merge and close my pull requests.

The worflow I'm following at the time is this one.

git checkout -b my-feature-123 develop
git add .
git commit -m "my changes"
git push origin my-feature-123
hub pull-request -m "my changes" -b develop
#enter guthub and merge PR
#run deployment 
git checkout develop
git pull origin develop # everything up-to-date

So I want to replace the #enter guthub and merge PR part with a command line merging command, till now nothing seems to work.

like image 217
user1532587 Avatar asked Dec 28 '18 14:12

user1532587


1 Answers

It should be possible to merge the feature branch from the command line using git's merge command. First, you'll need to checkout the branch you are merging to which in this case is develop:

git checkout develop
git merge --no-ff my-feature-123
git push

The --no-ff is used to prevent a fast-forward merge which is the behavior you'd want for gitflow.

like image 126
Erich Hansen Avatar answered Sep 22 '22 00:09

Erich Hansen