Reputation: 852
I have a master branch, and add_db branch for a simple project. I have done all my code edits and pushes on add_db. However, I want to merge all these commits into my master branch. When I try to create a pull request on github, I get an error stating: There isn't anything to compare.
I made sure I have base:master compare:add_db.
What can I do to fix this?
This is the repository for context: https://github.com/boxcarcoder/Task-List
I saw on another post that I can use git rebase --onto or git cherry-pick but I am unsure of how to use those. I am new to git. Thanks for taking the time to read this.
Upvotes: 2
Views: 11074
Reputation: 852
I did a git merge add_db to merge the branches, followed by git pull (git url) master --allow-unrelated-histories to update my local master branch to my remote master branch. Now that my local master branch has the commits of add_db and is up to date with the commits from my remote, I am now able to git push --set-upstream origin master. My github's master branch now has the commits of my add_db.
Essentially, I had to do a merge, pull, then push to update the master branch in my remote in github.
Upvotes: 0
Reputation: 6384
Git commits are linked list of commits with later commit having and branches are pointers to the commit reference of previous commit. C1<-C2<-C3<-C4<-C5
You can create merge request if your child branch originated from parent branch.
master
|
v
C1<-C2<-C3 new_branch
^ |
| v
C4<-C5<-C6
if you see commit history of both branches, first commit (head commit) for them is different. So you cannot create a merge request as both branches have started from a different history.
In your case:
master
|
v
C1<-C2<-C3
C4<-C5<-C6
^
|
add_db
In your case you can just compare and merge them, as merging them will create a new merge commit and align commit history.
master: C1<-C2<-C3
\
C7(merge commit)
/
add_db: C4<-C5<-C6
Also make sure you are always creating a new branch from other branch.
Upvotes: 2