This module looks big. Actually it is more about concepts and tasks per se are tiny.
Git is not only about storing versioned code but is also about communication. There are some communication patterns to follow that will make interaction with your peers and superiors easier and better structured, i.e. more efficient.
The collaboration flow highlighted in this module comprises:
A problem solving workflow, in general, comprises:
In software development the above maps as follows:
A problem can be e.g.:
When a problem is identified it should be reported as an issue in relevant repo context.
Issue details can contain Steps to Reproduce and environment details (bug), suggestions on the solution (feature or improvement request).
Once a problem is documented as an issue it can be assigned to someone. Issue reporter can assign himself or herself, or a team lead can assign the issue to someone from the team.
Solution suggestion itself is a commit of code (or text) that solves the problem (normally in a feature branch) submitted with a Pull Request (Merge Rerquest in other cloud VCS).
Solution alignment is a process where stakeholders or peers, or supervisors have an opportunity to conduct code review (cross-check the solution for correctness or safety, or ability to achieve the solution goal).
Depending on conventions in a team, a Pull Request author may assign a team lead or peers to review the PR. Alternatively peers may assign themselves to review the PR as per their capacity. The team lead may re-assign the PR to someone else.
Changes can be requested in the course of the Pull Request review.
Solution approval is a process where key stakeholders or decision makers confirm that the solution is appropriate.
Normally, review from at least two peers is required. This also depends on the team conventions.
Putting solution into life means it becomes a part
of the code base by merging into (or rebasing onto) master
or other production streamline branch.
This is normally done by one of reviewers or by a team lead once there are no non-resolved change requests and required number of approvals (e.g. two) are obtained.
GitHub offers Issues and Pull Request mechanics.
Skills to earn, improve or refresh:
master
To feel safe we shall play around with text. Actually, MarkDown is a type of code, just like HTML, as it gets interpreted to render a nice document view.
Note that it is good to start an issue title with a proper verb (like we do for commits):
Fix
for a bugAdd
for enhancement or a new featureChange
for enhancementJust imagine that someone fixing the issue will create a commit with the very same message at your issue title. It will establish a strong binding between the issue and commit that resolves it.
Read
Do
Option 1. You might have noted something not so easy to master or comprehend in the past modules. This might be a good source of an idea to create an issue on. Let’s take this as a need for improvement.
Option 2. The course materials may contain a broken link, a typo in the text, something like http://domain.com/a-very-long-url instead of nicely formatted link. Let’s take this for a bug.
Option 3. Course is really a Work In Progress and misses many modules to be populated with educational content. Let’s take this as a lack of a feature.
Option 4. Any other bug, need of improvement or lack of a feature.
Cannot invent a problem? No problem. Check this document full of typos. Or just ask your peers for support and ideas.
Simple issues (like typos) can be resolved with a single commit and without a discussion. But let’s learn on a simple case to be ready for more complicated ones.
The task is to
bug
or enhancement
)Check this issue #1 for example.
And remember, MarkDown is here to make your issue description easier to read.
Do
Check this issue #1 for an example.
You’re done.
You make a fork of a repo when you
What is nice with forks is that you can create a Pull Request into original repo from your fork’s branch!
NB! Cloning a repo and just pushing it up to your space doesn’t create a fork binding and will not enable cross-repositorial pull requests.
Read
Do
You need this skill in order to complete the following task.
Pull request is a device to propose code changes (consider .md
file
is some code as well, like HTML), have a spare pair of eyes to look
at (doing a code review), and approve a good solution.
Read
Do
git clone...
or update your local clone
master
of the forked repo (git checkout master && git pull
)git checkout -b <new-branch-name>
(branch name would give a general idea of the code associated with it)git push...
Resolves #3
somewhere
in the comment (3
is a number of an issue you can see beside its title).
GitHub will bind your PR to that issue and the issue will get closed
(as resolved) once your PR is merged.You may not assign reviewers if you’re not an owner of the repo or not a part of organization. Try identifying the owner or repo collaborators and mention them in a comment by their names. If unable to identify relevant persons then just skip this step.
Alternative
Send a pull-request to Kottans/mock-repo proposing a change.
It could be anything, really. If you have found a typo in README.md
-
great!
Take care to give your PR a meaningful name and description.
Please, do not suggest changes via GitHub Web UI, the target
is to emulate code contribution flow using branch-commit-push
techniques.
Please note, that your PR may not be reviewed quickly.
Something went wrong?
Seek for the help among your peers (e.g. in a chat). Also you may find this guide helpful when facing irrelevant commits problem.
Pull Requests are contributions. Many projects contain contribution
guidelines, many guidelines are quite applicable across projects.
Whenever you see CONTRIBUTING.md
it is worth reading before you
start contribution to a project.
You may find something useful or interesting in other projects’ contribution guidelines. Check this example 1, and this example 2.
It is a good practice to conduct a code review to make sure a PR introduces useful, bugless :smirk: code.
By convention, approvals from two code reviewers is required to approve a PR.
Code review can be as short as LGTM
(Looks Good To Me) with an approval
or a series of comments to the code with a Change Request.
Read
Do
LGTM
and approveAt any stage of PR the author may face a code conflict. GitHub will warn you. This section is intended to make you well prepared. No panics!
Read
NB! Resolving a conflict using command line is a preferred method in many cases.
Do
Once a PR is approved (e.g. by 2 code reviewers) the code proposal can be merged into master.
Read
Do
GitHub offers three merging strategies:
Opt for squash or rebase as these keep the git history linear.
Resolves #3
to make GitHub bind this PR with a relevant issue by
issue numberYou are done!
What if a PR should be closed without merge?
If you decide just to close a PR, i.e. reject it or cancel, you can do it with Close pull request button.
It is important to give a reason for your peers and future yourself. Reason shouldn’t be extensive, just a couple of clear words. Check this out for example.
Draft Pull Requests are the same as normal Pull Requests. The only difference is that a draft Pull Request cannot be merged into the repo codebase until it is finalized and ready to become a real code proposal.
Draft Pull Requests are good to open discussion on incomplete code, e.g. when you get stuck and need help or an advice.
Read
Introducing Draft Pull Requests
You did a lot and greatly improved your git and collaboration skills!
When done let others know you have passed this module.
This lets other know your progress and probably someone will ask you for some help in this module.
Where to communicate? In a chat you come here from :)
Now you are ready to efficiently collaborate with your teammates in a real project and contribute to Open Source Projects. Tell others that you are eager to get involved into any.
:gift: On GitHub you get subscribed for notifications when e.g. a new repo is created in your organization. You can unsubscribe from notifications on selected repos here or even from a particular organization. This would help to see only notifications you want.
Meanwhile you may want to become a Git Ninja.
Gist is a tiny repo, and normally used to keep simple, often single file code snippets or docs, that do not deserve to be a project and need no much collaboration via e.g. Pull Requests.
Read
Do
test.md
file in itProceed to Git workshop