...
git clone https://gerrit.onosproject.org/OnosSystemTest
In order to submit code for review, add your machine's public key to your user setup (after logging on gerrit.onosproject.org) - https://gerrit.onosproject.org/#/settings/ssh-keys.
The Walkthrough
Create and switch to a new branch. A branch is a divergence point from the existing code base. Any changes made in a branch are restricted to the branch.
Code Block language text $ cd ~/OnosSystemTest $ git checkout -b myBranch Switched to a new branch 'myBranch'
This creates a new branch named 'myBranch', off of the previous branch that we were in. This command will fail if there was already a branch of the same name. The command
git branch
can be used to list all of the branches to check that the name isn't already used. If a branch with the desired name is no longer needed, it may be deleted withgit branch -D <branchName>
and the above commands repeated to re-create a new branch.- Make changes to the code. This can be done in any way - IDE, text editor, whatnot.
- Test the changes. Run your modified or new test script.
- Commit the changes. Committing creates a snapshot of the changes made to the code so that may be revisited/manipulated later, but only in the branch where the changes were committed. The command
git status
allows one to view the files that were modified.git add <file>
adds a file to the pool to commit. Once all files are added,git commit -m "<message>"
creates a snapshot with <message> as its description.git log
may be used to list all of the commits that have been made, with the most recent commit at top. Pull upstream changes. The repository on the development machine should be synchronized with the upstream OnosSystemTest source repository.
Upstream changes are always applied to the master branch. We first switch back to master with
git checkout
, before pulling downloading the changes in the upstream source repository withgit pull
:Code Block language text $ git checkout master Switched to branch 'master' $ git pull --ff-only origin master
Sync the branch with updated master. The updates pulled to master must be explicitly applied to the branch intended for code review. This is done by switching back to the development branch and using
git rebase
.Code Block language text $ git checkout myBranch Switched to branch 'myBranch' $ git rebase -i master
The default editor will be opened with the list of commits that have been made to the branch locally since its creation. Saving and closing this file causes the changes from the master branch to be incorporated into the branch. Any merge conflicts (e.g. a file modified in both the local and master branch) will interrupt the process. In
git status
, the conflicting files will appear under "Unmerged paths" as "both modified". If this happens, the file(s) must be edited and committed before the rebase is continued:Code Block language text $ git rebase -i master error: could not apply ca081b6... Initial commit for information persistence. $ [modify the file in order to resolve the merge conflicts] $ git add [modified_file_name] $ git rebase --continue Successfully rebased and updated refs/heads/myBranch.
Submit code for review. Once the branch is synchronized, it may be submitted for review with
git review
.Code Block $ git review
This submits the changes with the branch name as its topic.
...