Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git refs merge vs head in pull request

Tags:

git

github

pull

The refs/pull// head refers to head of the PR but what about the refs/pull//merge , I am not finding any git commits which are shown as part of /merge in commit history .what does this /merge exactly mean for a PR and when PR has multiple cmmits to it , when PR is open, When PR is clsed etc

$ git ls-remote
From git@<repo url>
01c8cd97857c21cfc5d413bd64e3c0e8cc8fd03d        HEAD
37b88346a9edb426f676d080be502a1d4349c499        refs/heads/PR1
6fda26f078c00adf518ec620e94f54daa85bb894        refs/heads/PR1-1
bd88e471db4127f066b3b2f1d699b8296ca62f6d        refs/heads/PR5
25b5eec47ca186a778c93439cd81e8a4125b5d6f        refs/heads/PR6
58a82cf11218991f8f544a14ef6c57d3963690ee        refs/heads/PR7
a5831973e1a4561527551a8bc8a9d5f9436f004b        refs/heads/Pr2
01c8cd97857c21cfc5d413bd64e3c0e8cc8fd03d        refs/heads/develop
442c0bc7f8b3872660d48cbd42690be677314b94        refs/heads/master
37b88346a9edb426f676d080be502a1d4349c499        refs/pull/1/head
2db24e8a6a53ce006694c4c5db1886df44620372        refs/pull/1/merge
a5831973e1a4561527551a8bc8a9d5f9436f004b        refs/pull/2/head
4ea1814dda65e2ca8572fbbc5da9cc8141391ab8        refs/pull/2/merge
6fda26f078c00adf518ec620e94f54daa85bb894        refs/pull/3/head
b6cde57523fc73ce08dd7e588eeb606c3f047136        refs/pull/3/merge
442c0bc7f8b3872660d48cbd42690be677314b94        refs/pull/4/head
58a82cf11218991f8f544a14ef6c57d3963690ee        refs/pull/5/head
e4a82d455b8b8e81b70dfbf4f6d79a1fb5158cbb        refs/pull/5/merge
bd88e471db4127f066b3b2f1d699b8296ca62f6d        refs/pull/6/head
e8825e286aa9c36c04046c5d4ac85c9d7a4ebf5c        refs/pull/6/merge
25b5eec47ca186a778c93439cd81e8a4125b5d6f        refs/pull/7/head
ed262d8c4766b037207f3113b634c777b3a0af37        refs/pull/7/merge

for ex. 25b5eec47ca186a778c93439cd81e8a4125b5d6f refs/pull/7/head ed262d8c4766b037207f3113b634c777b3a0af37 refs/pull/7/merge/

what is hte significance of ed262d8c4766b037207f3113b634c777b3a0af37 refs/pull/7/merge/ and this commit id ed262d8c4766b037207f3113b634c777b3a0af37 is not found anywhere

like image 318
Ramprasad Avatar asked Aug 26 '20 09:08

Ramprasad


People also ask

What is refs pull merge?

The refs/pull/<number>/merge is a reference created by GitHub to keep track of what would happen if a pull request was merged. It references the merge commit between refs/pull/<number>/head and the destination branch (e.g. master ). You can think of it as a "future" commit.

Is Git merge the same as a pull request?

A Git pull request is essentially the same as a Git merge request. Both requests achieve the same result: merging a developer's branch with the project's master or main branch. Their difference lies in which site they are used; GitHub uses the Git pull request, and GitLab uses the Git merge request.

What is ref and head in Git?

git/refs/ . In Git, a head is a ref that points to the tip (latest commit) of a branch. You can view your repository's heads in the path . git/refs/heads/ . In this path you will find one file for each branch, and the content in each file will be the commit ID of the tip (most recent commit) of that branch.

What is head pull request?

Changes will be added to this repository via the pull request. Following the example above, the base repo is your colleague's repo. Head: Head is the repository containing the changes that will be added to the base. Following the example above, this is your repository (your fork of your colleague's repo).

What is a merge request in Git?

A merge request is simply a request from a user to merge their code from one branch to another, typically to the master branch. Like the Git pull request, the Git merge request allows the team members to discuss the suggested changes and merges, offering feedback and possibly adding new commits to make the process smoother.

What are changes in git pull request?

All the commits made on the source branch after the merge-base commit will be considered as Δchanges. These are the commits that will be listed in the commits tab for your pull request. You can pass any type of Git reference to the merge-base command.

What is the difference between merge branch commit and merge pull request?

Then, when the PR is resolved, a merge pull request commit is created. The destination branch is moved to that merge pull request commit. The merge branch commit and the merge pull request commit have different SHA1. However, they might not contain any difference if no change is made between the two commits.

What does ReFS/pull/1/head contain?

The refs/pull/1/head contains the commits of pull request #1 (further pull requests will be sequentially numbered after that). Git won't fetch them by default, so you have to ask it to do so explicitly:


1 Answers

The refs/pull/<number>/merge is a reference created by GitHub to keep track of what would happen if a pull request was merged. It references the merge commit between refs/pull/<number>/head and the destination branch (e.g. master).

You can think of it as a "future" commit. GitHub (as well as other Git-based collaboration platforms) use this technique to determine whether the pull request would successfully merge with all the checks passing and no merge conflicts.

Atlassian has a good explanation of the reasoning behind this server-side implementation detail here:

When you view a pull request, you’re seeing what the resultant merge commit will actually look like. We do this by actually creating a merge commit behind the scenes, and showing you the difference between it and the tip of the target branch.

They're obviously talking about Bitbucket, but the same applies to GitHub.

like image 132
Enrico Campidoglio Avatar answered Oct 23 '22 04:10

Enrico Campidoglio