Skip to content

Commit 1ff11c8

Browse files
author
svetlana-v
committed
Add git tips
1 parent 298713f commit 1ff11c8

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ All feedback, pointers and comments are very welcome! We hope you find this repo
99
## Domains
1010
* [Natural Language Processing](nlp)
1111
* [Structured Data](structured_data)
12-
* [Machine Learning in Production](mlip)
12+
* [Machine Learning in Production](mlip)
13+
* [Software Architecture](sa)

sa/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ML6 Software Architecture Quick Tips
2+
3+
Current content:

sa/git_tips/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Using Git in our daily workflow
2+
3+
Git is an essential tool in our day-to-day coding life. Below you will find Git hints and best
4+
practices and conventions that we aim to follow at ML6.
5+
6+
7+
## Naming conventions
8+
9+
* Always start development with creating a new branch.
10+
* Name the branch according to our conventions.
11+
* Use feature/ prefix for a new feature and `bugfix/` for fixing a bug.
12+
* Separate the words in the branch name with dash.
13+
14+
#### Examples:
15+
16+
* `feature/docs`
17+
* `bugfix/data-pipeline`
18+
19+
20+
## Commit messages
21+
22+
* Write clear commit messages. A commit message should be a short summary of your changes.
23+
* Use imperative, present tense statements (e.g. 'change', and not
24+
'changed' or 'changes').
25+
* Try to limit the message to about 50 characters or less to keep it clear and readable.
26+
27+
#### Examples:
28+
29+
* `Add io module documentation`
30+
* `Delete preprocessing step in data pipeline`
31+
32+
33+
## Clean commit history
34+
35+
* Only commit the code you tested.
36+
* Make sure the change is a logical chunk that is completed and has no side effects.
37+
* Keep separate parts of your change in separate commits. For example, fixing two different bugs
38+
should produce two separate commits. This will make your commit history clean and structured.
39+
In addition, it would be easier to possibly roll back if something goes wrong, and will also help
40+
reviewers to understand the changes faster.
41+
* Before merging, small commits representing intermediate steps in context of a bigger change or
42+
made in response to PR comments can be cleaned up by squashing them.
43+
44+
### Some useful Git commands
45+
46+
#### `git commit`
47+
48+
* `--amend`
49+
Replaces the last commit done with a new one.
50+
51+
> Use the `--no-edit` flag if you want to keep the commit message.
52+
53+
> Also make sure to to check what your last commit was before amending.
54+
55+
* `--fixup HASH`
56+
Creates special commit with prefix linked to the specified commit. This commit can be used in
57+
combination with `rebase --autosquash` to correct past commits.
58+
59+
#### `git rebase`
60+
61+
* `--onto`
62+
Allows the user to specify the starting point of the rebase.
63+
64+
* `-i`
65+
Interactive rebase - allows the user the select which commits to rebase.
66+
67+
* `--autosquash`
68+
Can only be used with the interactive rebase. Will automatically squash commits with the prefix
69+
`squash!` or `fixup!` with linked list while rebasing.
70+
71+
> Pushing to remote: don’t forget that the above commands changes the commit. This means that to push
72+
it to a remote branch you’ll need to use the `--force` flag or `--force-with-lease` flag.
73+
`--force-with-lease` is a safer option than `--force` as it prevents overwriting the remote if
74+
additional commits have been added to the branch.
75+
76+
#### `reset` vs `reverse`
77+
78+
* `git reset HASH` or `git reset HEAD~N`
79+
Undo local changes by moving pointer back to the specific commit. This means that it changes the
80+
commit history and is not recommend to be used for public commits.
81+
82+
`--mixed` (default option) makes it so that only the pointer is moved back. This can be used to
83+
squash your latest commits.
84+
85+
`--hard` flag makes it so that the working directory is also updated.
86+
87+
* `git revert HASH` or `git revert HEAD~N`
88+
Undo changes by adding a new commit that undoes all changes. This means that it does not change the
89+
commit history and is the recommended way of correcting public commits.
90+
91+
> Both of these commands can also be executed on a file level.
92+
93+
#### `git rev-list HASH..HEAD`
94+
95+
Lists commit objects in reverse chronological order since commit hash.
96+
97+
98+
## Useful resources
99+
100+
Want some tips on how to fix your Git mistakes and keep your commit history clean?
101+
Check [ohshitgit](https://ohshitgit.com).

0 commit comments

Comments
 (0)