I work as a part of a team. Our process is to create a separate branch, work on the separate branch, then push that branch to 'origin' and make a pull request to master.
I am trying to get better with the default command line Git.
Then another person makes a pull request on a branch. Is there an easy way to pull that branch to my local and check out the branch so I can test the code before approving the pull request?
To check out a pull request locally, use the gh pr checkout subcommand. Replace pull-request with the number, URL, or head branch of the pull request.
Pull requests are closed automatically whenever the maintainer merge the changes through the web interface. If he merged using the command line, it will be closed as soon as he pushes the code back to Github. So if a PR is still open, it means it is not merged.
There's even the possibility of checking out the "remote branch" directly, no need to create a local branch (git will say you are working on detached HEAD state), so, using Sajib's example:
git fetch origin
git checkout origin/whatever
You can checkout the branch (say, feature
) where pull request is created.
$ git fetch
# create a new branch 'test-feature' with 'origin/feature' history
$ git checkout -b test-feature origin/feature
# now test here
You can merge master
into test-feature
branch and test if all is ok!
$ git pull origin master
# test more
First, you have to fetch branch:
git fetch origin
Then you can list all files that have been changed:
git diff --name-only origin/master
Disclaimer: I am the creator of Pull Dog, but I truly believe it solves this particular issue very well.
I made a GitHub app called Pull Dog. For every pull request you open, it takes your docker-compose.yml
file, creates a new test environment, runs docker-compose up
on it, opens the exposed ports in the firewall, and posts a link with connection details for each of these ports.
Portainer (15k stars on GitHub as of writing) is using it for their project. You can go look at any of their pull requests to see how it behaves.
Highlights:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With