Skip to content

Instantly share code, notes, and snippets.

@vijayrawatsan
Last active June 11, 2018 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijayrawatsan/fa498e01d5410867af6730da430e05bd to your computer and use it in GitHub Desktop.
Save vijayrawatsan/fa498e01d5410867af6730da430e05bd to your computer and use it in GitHub Desktop.
Locally merge pull request
# clean repo of any unstaged, uncomiited data
cd {repoPath} && git reset --hard && git clean -d -x -f
# fetch all remote branches
cd {repoPath} && git fetch --all
# fetch pr head from remote and create a new branch named {prNumber}-{uuid}, you can generate any uuid lib or simply use date.getTime()
cd {repoPath} && git fetch origin pull/{prNumber}/head:{prNumber}-{uuid}
# checkout baseRef of the Pull Request
cd {repoPath} && git checkout {baseRef}
# fetch and merge remote data
cd {repoPath} && git pull origin {baseRef}
# create new branch from refreshed baseRef
cd {repoPath} && git checkout -b {baseRef}-{uuid}
# merge {prNumber}-{uuid} into {baseRef}-{uuid}
cd {repoPath} && git merge {prNumber}-{uuid}
# build code. This part may vary depending on the project structure and build tools
cd {repoPath} && mvn clean install -DskipTests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment