3 Getting Started¶
3.1 Initialize a repository¶
git initinside the directoryfirst_git_project.ls -lashows the directory.git. This lets us know that git has been initialized in this directory.
3.2 Where git files are stored¶
leave everything in
.gitalone.you can check project level config at
cat .git/config.DO NOT delete this directory. All the tracking is stored here.
other version control tools may store tracking in every folder.
not in git! everything is in
.git.
3.3 First commit¶
create a file
first_file.txt.make git track this change.
First,
git add .adds ALL changes in the current directory.adding does not track changes (yet).
track changes using
git commit -m "Initial commit". This commits all changes that were added.
Process:
Make changes.
Add changes.
Commit changes with a message.
3.4 Write commit messages¶
How do we write good commit messages? Best practices:
A short single-line summary (less than 50 characters)
Optionally followed by a blank line and more complete description
Still keep each line to less than 72 characters (for improved viewability)
Write commite messages in present tense, not past tense
“fix for a bug” or “fixes a bug”, not “fixed a bug.
This is what’s inside the commit.
Bullet points are usually asterisks or hyphens
Can add “tracking numbers” from bugs or support requests
Can develop shorthand for your organization
eg.: “[css, js]”, “bugfix:”, “#38405 -“
Be clear and descriptive
bad: “fix typo”
good: “add missing hyphen in project section of HTML”
bad: “update login code”
good: “change user authentication to use blowfish”
bad: “updates member report, we should discuss if this is right next week” (extra information doesn’t have place in permanent commit log)
Example:
“ghi2394 - Fixes bug in admin logout
When an admin logged out of the admin area, they
could not long in to the members area …”
3.5 View the commit log¶
use
git logto see commit log/historycommit unique_commit_IDgit help logto use other optionsgit log -n 5limits number of commits to 5 most recentgit log --since=2020-01-01all commits since jan 1st, 2019git log --until=2021-01-01git log --author="makto"part of the name sufficesgrepstands for “globally search for regular expressions”git log --grep="init"case sensitive on linux