5. Foobarsystem Co.,LTD
How does it work?
● Tracking changes in files.
● Committing changes.
● Working directory, Staging area and the
remote repository
● .git folder
10. Foobarsystem Co.,LTD
Initializing a Repository
➔ git status: show the current git repo status
➔ git init: Initializing git repo
Add .git folder for repo setting
11. Foobarsystem Co.,LTD
First commit
➔ touch readme : create a new readme file
➔ edit readme : use favorite text editor
➔ git status : show the current git repo status
➔ git add : Adds file to track or submit changes
to commit
➔ git commit -m “commit message” : commits
changes in added files
➔ git rm <filename> : Delete a file
12. Foobarsystem Co.,LTD
Commit history
git log : show commited log and information
git log --since=2.weeks
git diff <file> : compare local change and
current commit
14. Foobarsystem Co.,LTD
Branching
git branch : show branches and current branch
git checkout -b <branchname> : create and
checkout the new branch from current branch
git branch -d <branchname> : delete specified
branch
15. Foobarsystem Co.,LTD
Working with remote
➔ git remote add <shortname> <remote repo>
➔ git remote : show current remote link
➔ git remote -v : show shortname and url
remote respository
➔ git push -u origin master
16. Foobarsystem Co.,LTD
Pushing and fetching
➔ git push origin master : Pushed commits to
origin remote
➔ git fetch origin : checks the latest in origin
➔ git merge origin/master : merge
origin/master with local current branch
➔ git pull : merge remote repository to current
local repository
18. Foobarsystem Co.,LTD
Git ignoring files
$ cat .gitignore
# a comment - this is ignored
# no .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the root TODO file, not subdir/TODO
/TODO
# ignore all files in the build/ directory
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .txt files in the doc/ directory
doc/**/*.txt
21. Foobarsystem Co.,LTD
Why gitflow?
● Based on the graph previous slide
● Shortcuts for repetitive tasks
● Branch naming convention
“<prefix>/<name>”
● Fast to develop
● 2 Main branches
23. Foobarsystem Co.,LTD
Feature branches
May branch off from:
develop
Must merge back into:
develop
Naming convention:
anything except master,
develop, release-*, or hotfix-*