• No results found

Git Commit Management

N/A
N/A
Protected

Academic year: 2021

Share "Git Commit Management"

Copied!
38
0
0

Loading.... (view fulltext now)

Full text

(1)

Git

Commit Management

Juraj Oravec

Slovak University of Technology in Bratislava

(2)

Git – basic workflow

Remote repository

Local repository (.git/)

Staging area (index)

(3)

Git – basic workflow

Remote repository

Local repository (.git/)

Staging area (index)

(4)

Git – recall: summary

git status

git add filename

git rm filename

git clean -d -i

git reset filename

git checkout filename

(5)

Git – basic workflow

Remote repository

Local repository (.git/)

Staging area (index)

(6)

Git – hash of commit

hash is a unique identifier of each commit

hash is a hexadecimal (HEX) number calculated using parent node’s unique identifier and the difference between the new version

and its parent node

(7)

Git – committing new changeset

git commit –m “message”

(8)

Git – committing message

git commit –m “type[scope]: description”

type:

bugfix – fix a bug (patch): ver. 1.0.0 → 1.0.1

minor – minor change (feature): ver. 1.0.0 → 1.1.0

major – major change (breaking change) : ver. 1.0.0 → 2.0.0docs – change/update in documentation (readme)

refactor – code changes focused on improving its readability

scope (optional): specify what has changed (preferably in 1 word)

(9)

Git – advanced committing tools

git commit --file=filename

commits new changeset with message given in filename

git commit --dry-run

summarizes what is going to be committed

git commit --dry-run --short git commit -n --short

(10)

Git – pushing commits

git push

pushes commits from local repository to remote repository

git push –f

git push --force

forces push ignoring (deleting!) conflict commits (rewrites history!)

git push –u origin master

(11)

Git – commit logs

git log

show log of all commits

(12)

Git – checking difference

git diff HEX1 HEX2

compares the differences between commits pointed by HEX1 and HEX2

git diff HEX1 HEX2 --name-status

(13)
(14)

Git – fake commit information

git commit –m “info” --author=‘name <[email protected]>’ commits new changeset as author name

git commit –m “info” --date=‘date time’ commits new changeset logging override date date

Date and time format: YYYY.MM.DD HH:MM MM/DD/YYYY HH:MM

(15)

Git – commit bugfixing

git commit --amend –m “message”

replaces (deletes!) tip commit by new commit with new message

git commit --amend --no-edit

replaces (deletes!) tip commit by new commit with old message

Note:

Forced push is necessary, if the original changeset was already pushed! Meanwhile, the original changeset could be pulled by other user!

(16)

Git – commit bugfixing

(17)

Git – tagging commit

tag is a pointer to a specific commit just before a tag was created

git tag git tag –l

git tag --list list tags

Note:

(18)

Git – removing tag

(19)

Git – forcing tag

git tag “tag” --force overrides the non-unique tag

(20)

Git – pushing and pulling tags

git push --tags

pushes commits up to the last tags

git push origin “tag”

pushes to remote URL origin all commits up to commit tagged by “tag” (including)

(21)

Git – commit logs

git log

show log of all commits

git log --graph

(22)

Git – selecting sequence of logs

git log –number

shows last number logs

git log HEX1..HEX2

shows logs from hash HEX1 to HEX2

git log HEX1..HEAD

shows logs from hash HEX1 to HEAD

git log HEX1..master

(23)

Git – selecting logs by date

git log --since=“YYYY-MM-DD”

show logs since date year YYYY, month MM, day DD

git log --until=“YYYY-MM-DD”

(24)

Git – searching for logs by pattern

git log --author=user

shows just commits of selected user

(25)

Git – searching for logs by commit changes

git log –G‘RegExpString’

finds commits which modified a line that mentions a particular string (finds commits having the blob including the string)

String can be defined using regular expression format

git log –I‘RegExpString’

(26)

Git – logging formats

git log --pretty=format show log of commits in set format:

oneline – dense 1-line (SHA, branch, message) short – shortened (SHA, branch, author, message) medium – default (SHA, branch, author, date, message)

full – full (SHA, branch, author, commit, message)

fuller – fuller (SHA, branch, author, date, commit, commit-date, message) raw – raw (SHAs: commit, tree, parent; author, committer, message)

Note:

(27)

Git – summarized logs

git shortlog

sorts logs of commits by authors

git shortlog –c

git shortlog --committer

sorts logs of commits by committers (not authors)

git shortlog -s

(28)

Git – summarized logs

git shortlog –e

git shortlog --email

sorts logs of commits including e-mail addresses

git shortlog --after=DATE

sorts logs of commits more recent than DATE

(29)

Git – fetching commits

git fetch

downloads changesets from remote repository to local repository

git fetch --dry-run

shows what would be done without any changes

git fetch -f

(30)

Git – checkouting commits

git checkout

updates/restores files in current directory from staging area or switches between branches

git checkout -- filename

discards (delete) changes in working directory by reloading file

(31)

Git – checkouting to a specific commit

git checkout tag

updates files in current directory by commit tagged by tag

git checkout HEX

updates files by commit identified by hexadecimal identifier HEX

git checkout master

(32)

Git – pulling commits

git pull

git pull –ff

downloads and updates changes from remote repository to local repository (git pull = git fetch + git merge)

– fast-forward: merging does not create commit (default)

git pull --no-ff

(33)

Git – tagging commit

(34)

Git – basic workflow

Uploading changes: Downloading changes:

git add . git pull

git commit –m “…” git merge

git pull

git merge

(35)

Git – summary

git commit -m “message” git tag tag

(36)

Git – summary

Remote repository

Local repository (.git/)

Staging area (index)

(37)

Git – outlook: project from git basics

Remote repository

Local repository (.git/)

Staging area (index)

(38)

References

Related documents

DC measurements were made for the offset voltage and the quiescent current for five units. The average values are reported in Table 2. The design creates a very accurately

Based on this format we developed an architectural pattern language of cloud-based applications: through interrelation of patterns for cloud offering descriptions and

Red: Supply pipe belonging to property owner, Blue: Water main, Company responsibility Yellow: If Company Meter Installed, Company responsible for meter installation only Yellow:

Prudent brokers will generally wish to see some evidence of an MGA’s authority before they agree to introduce business to the MGA. Rather than disclosing the underwriting agreement –

Consumer Advocate, Steve Burgess, following recent rate filings by leading medical malpractice insurers writing in Florida. The Office conducted the hearing in Tallahassee, Florida

Managing agents shall ensure that there is a demonstrable and transparent written Pricing Policy which provides a clear expectation of pricing levels and

Authorize the Chief Executive Officer to negotiate and award excess liability insurance policies with up to $250 million in limits at a cost not to exceed $4.1 million for the 12-

The main purpose of this study was to investigate the impact of training and development on Employee Performance and Productivity in United Banks Limited (UBL)..