-
Notifications
You must be signed in to change notification settings - Fork 164
Git Information
Below are information for a typical workflow.
We follow the branching model described in http://nvie.com/posts/a-successful-git-branching-model.
Hence, all development forks of and, once it is tested and stable, merges into the develop
branch. The master
branch only gets updated with code that is close to a release.
To fork the main branch to your own repository, make changes there, and issue a pull request, proceed as follows:
First, on the web interface, press Fork to fork the repository to your account. Next, run
$ git clone https://github.com/YOUR_LOGIN/modelica-buildings.git
# Make some changes
$ cd modelica-buildings/
# Add a remote upstream so that you can get changes from the develop branch
$ git remote add upstream https://github.com/lbl-srg/modelica-buildings.git
# Fetch upstream changes, without changing local files
$ git fetch upstream
$ emacs README.md
$ git commit -m "Made changes to README.md" README.md
# Merge the changes from the upstream master (the main repo) with your local files
$ git merge upstream/develop
# Push the changes to your repository
$ git push
$
Finally, on the web interface of your account, issue a Pull Request so that the changes
are merged to the develop
branch.
To add a new feature, we branch of from the develop
branch, add the feature, and
when it is stable, merge it back to the develop
branch. As an example, we show below how
to modify the README.md
file using a branch we call updateReadme
.
$ git clone https://github.com/lbl-srg/modelica-buildings.git
Cloning into 'modelica-buildings'...
remote: Counting objects: 68, done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 68 (delta 13), reused 66 (delta 11)
Unpacking objects: 100% (68/68), done.
$ cd modelica-buildings/
$ git branch
* develop
$ git checkout develop
Already on 'develop'
$ git checkout -b updateReadme
Switched to a new branch 'updateReadme'
$ git branch
develop
* updateReadme
$ echo "Added a line in updateReadme" >> README.md
$ git commit -m "Updated README.md" README.md
[updateReadme 25b562c] Updated README.md
1 file changed, 1 insertion(+)
$ git push origin updateReadme
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 397 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/lbl-srg/modelica-buildings.git
* [new branch] updateReadme -> updateReadme
$ echo "Added a second line in updateReadme" >> README.md
$ git commit -m "Updated README.md a second time" README.md
[updateReadme f8f29c5] Updated README.md a second time
1 file changed, 1 insertion(+)
$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 384 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/lbl-srg/modelica-buildings.git
25b562c..f8f29c5 updateReadme -> updateReadme
$ git checkout develop
Switched to branch 'develop'
$ git merge updateReadme
Updating 7034cfd..f8f29c5
Fast-forward
README.md | 2 ++
1 file changed, 2 insertions(+)
$ git push
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/lbl-srg/modelica-buildings.git
7034cfd..f8f29c5 develop -> develop
$
Note that in the first push command, we used git push origin updateReadme
to have the branch pushed to the github servers.
Finally, we delete the branch updateReadme
on the server and the local repository.
$ git push origin --delete updateReadme
To https://github.com/lbl-srg/modelica-buildings.git
- [deleted] updateReadme
$ git branch -D updateReadme
Deleted branch updateReadme (was f8f29c5).
$