Skip to content

Git Workflow

Hosur Narahari edited this page Aug 31, 2018 · 2 revisions

Steps to create pull request

Creating a Fork

Just head over to the GitHub page (https://github.com/Impetus/eth-jdbc-connector) and click the "Fork" button.

Clone your fork to your local machine

git clone https://github.com/YOUR_USERNAME/eth-jdbc-connector.git

Keep your fork up to date

git remote add upstream https://github.com/Impetus/eth-jdbc-connector.git

  • Fetch from upstream remote and merge it to your master
git fetch upstream
git checkout master
git merge upstream/master

Create and checkout a new branch. Do all your development in this branch

git checkout -b newfeature

Before making a pull request

Fetch upstream master and merge with your repo's master branch

git fetch upstream
git checkout master
git merge upstream/master

If there were any new commits, rebase your development branch

git checkout newfeature
git rebase master

Run all unit tests and integration tests including the one you have written for newfeature

mvn test
mvn verify -P integration-test

Create a pull request.

https://help.github.com/articles/creating-a-pull-request/


Steps to rebase branch with master

Execute following commands in the branch to be rebased.

git rebase master

Resolve the conflicts if any.

git add <files resolved>
git rebase --continue

Continue above steps for every conflict arised.

Merge remote branch to your local one.

git pull origin <branch>

If conflict arises, resolve it and execute below two commands.

git add <resolved files>
git commit -m "<commit message>"

Push your local changes to remote using below command.

git push -u origin <branch>

Steps for merging pull request for repository maintainer

Once the Repository maintainer gets a pull request,

Before running the workflow add the following in vim .git/config
fetch = +refs/pull/*/head:refs/pull/upstream/*

After you add your config for upstream will look something like this.

[remote "upstream"]
        url = https://github.com/Impetus/eth-jdbc-connector.git
        fetch = +refs/heads/*:refs/remotes/upstream/*
        fetch = +refs/pull/*/head:refs/pull/upstream/*

Merge the pull request after code verification, unit and integration testing

git fetch upstream 
git checkout master  
git merge upstream/master  
git checkout -b pull#9 pull/upstream/9  
mvn clean install -P integration-test 
git checkout master
git merge pull#9 
mvn clean install -P integration-test 
git push upstream master 
git push origin master 
git branch -d pull#9

Alternatively Merge the pull request from forked branch

git fetch upstream
git checkout master
git merge upstream/master
git checkout -b newfeature-test master
git pull https://github.com/forkuser/forkedrepo.git newfeature
mvn clean install -P integration-test
git checkout master
git merge --no-ff newfeature-test
mvn clean install -P integration-test
git push upstream master
git push origin master
git branch -d newfeature-test