Start by forking a repository, to make changes without disturbing others and vice versa. Maintain a master branch in our fork, and neatly segregate proposed changes in various branches. Each branch is then merged back into our master. Master is then pushed online. Finally, a Pull Request (PR) is sent upstream from our fork.
If you use open-source in any way shape or form, you should contribute back. There are many ways to contribute. Explore or just ask.
Fork
http://help.github.com/articles/fork-a-repo
We can fork any source. In this instance, we will use a project hosted on github as an example. Find the online repository and click on fork.
Clone
We make a local clone of our online repo.
$ git clone https://github.com/josephg5/tinylaunch.git
From now on, everything happens inside our repo directory.
$ cd tinylaunch
$ git remote -v
Upstream
Make sure our clone is in sync with upstream.
$ git remote add upstream https://github.com/arpuss/tinylaunch.git
Fetch
http://help.github.com/articles/syncing-a-fork
$ git fetch upstream
$ git checkout master
$ git merge upstream/master
Verify and change url, if you got remote error.
$ git fetch upstream
fatal: remote error:
Repository not found.
$ git remote set-url upstream https://github.com/arpruss/tinylaunch.git
$ git fetch upstream
This brings our fork's master branch into sync with the upstream repository, without losing local changes.
Push
Syncing only updates the local clone of our online repository. To update our fork on github, we must push our changes.
$ git push
Change url from git to https and push again, if you got remote error.
$ git push
fatal: remote error:
You can't push to git://github.com/josephg5/tinylaunch.git
Use https://github.com/josephg5/tinylaunch.git
$ git remote set-url origin https://github.com/josephg5/tinylaunch.git
$ git push
http://help.github.com/articles/pushing-to-a-remote
Branch
Our base framework is ready. Any changes should be made via branches. This assists our change management.
$ git branch
* master
$ git branch working
$ git branch
* master
working
Log
Most recent changes are listed on top. The first line should list our new working branch.
$ git log --oneline --decorate --graph --all
Checkout
We need to switch branches, before we can work on them.
$ git checkout working
Switched to branch 'working'
$ git branch
master
* working
Change
Now we have reached a stage where we can start making changes to various files - create, edit, delete, etc.
Commit
$ git commit -a -m 'commit comment'
Merge
Our working branch is now ready to be merged back to master. After the merge, this working branch is not needed anymore, and can be deleted.
$ git checkout master
$ git merge working
$ git branch -d working
A simple Change Management Strategy:
Create a branch for each set of changes. Merge back to master, and delete branch. Push it online.
No comments:
Post a Comment