I. Working on parallel branches, merging them, pushing to Github
On my local machine, create a folder to contain for the entire project.
In the newly created folder, on the command line, issue:
git init
then, pull the remote master repository from Github.com by:
git clone https://github.com/bpan2/httplinkcheckerOnce cloning is done, at the current folder, create two new branches to implement two features for json and all/good/bad flags by issuing:
git checkout -b issue-json master
git checkout -b issue-flags masterImport the master branch into Eclipse with the option of "Select nested projects".
Implement the above two features in their corresponding local branch.
During the entire implementation process, I staged and committed changes via Linux command line.
For each commit, I tried to make the content as atomic as possible. By this way, it could make reversing the modification easier.
-
Once the implementation is completed, I ran into some issues when trying to push my local branches to the remote repository.
I named my remote branch with different names from my local branches. Even though I triedgit push origin issue-json:issue-4
I kept getting the error message which states:
Updates were rejected because a pushed branch tip is behind its remote counterpart
After multiple times of failed attempts to solve the issues, I resorted to the most primitive method:
1. deleted the corresponding remote branches for the two
features
2. within each local branch for the two features, change the
name of the branch by issuing:
git branch -m issue-4
git branch -m issue-5
3. at the command line, issue:
git push -u origin issue-4
git push -u origin issue-5
The resulting remote branches can be found via:
https://github.com/bpan2/httplinkchecker/tree/issue-4
https://github.com/bpan2/httplinkchecker/tree/issue-5
-
Merging issue-4 and issue-5 branches with the master branch
The merging of issue-4 branch with the master branch goes without any issue. However, multiple conflicts occurred when merging issue-5 branch with the master branch.
The conflicts involved tow java classes. By examining the conflicts, no real conflicts exist in terms of the implementation codes. Once finishing removing the signs generated by git, the issue-5 branch is merged with the master branch without any issue after the changes were committed.
After completing the above two merges, I retrieved those two merge commits by issuing:
git log --merges Filing issue-4 and issue-5 and closing them with the following two links:
https://github.com/bpan2/httplinkchecker/issues/1
https://github.com/badalsarkar/Blink/issues/5
II. Useful Details
Using Windows Subsystem for Linux version 2(WSL) on Windows 10:
To use WSL, issue "bash" at the Powershell command line.How to import local repo into Eclipse:
While importing a local Git repository with multiple branches, don't forget to tick the checkbox for "Select nested projects". Otherwise, you might not be able to switch among branches within Eclipse.How to switch branches using Eclipse by using Team:
Right click on my project,
select Team -> Branch -> switch between existing branchesCreating a new remote branch and push a local branch to it:
git push -u origin issue-4Filtering the git log to display/not to display merge commits:
1 to display: git log --merges
2 not to display: git log --no-merges
Top comments (0)