Beruflich Dokumente
Kultur Dokumente
Glib Ivashkevych
junior researcher, NSC KIPT
Collaborate
allows many developers to work on the same codebase
git repositories
tracked files + metadata = repository
Create repository:
> git init
git repositories
Working directory snapshot of the project Staging area what to store in next commit To see the current state:
> git status
git commits
Record of some state of the project in git directory Only staged files are committed > git add myfile.py > git commit
git rm
unmodified
<edit file>
git add
gi
co
i m m
staged
git add
modified
git branches
Separate line of development Actually, just a reference to particular commit lightweight List branches: > git branch
git branches
Create branch: > git branch <branch name> > git branch <name> <starting point> Checkout branch: > git checkout <name> Or all at once: > git checkout -b <name> > git checkout -b <name> <point>
git merges
Eventually, youll need to stitch branches together. This operation is called merge. Merge br1 into br2: > git merge br1 br2 Merge br1 into current branch: > git merge br1
git conflicts
By default, git commits, if merge was successful (always true for fast-forward merges). Use --no-commit to avoid this. Sometimes, git fails when merging. This is called merge conflict. Resolve conflict by hand and commit yourself in such a case.
git remotes
You can connect your repo to as many outside repositories, as you wish. Such repos are called remotes. To add/remove remote: > git remote add <name> <URL> > git remote rm <name> origin is a repository from which you cloned.
developer
developer
developer
manager
dev private
dev private
git config
Config files: .git/config ~/.gitconfig /etc/gitconfig To set option: > git config [--global|--file|--system] <option> <value> > git config --global user.email mail@gmail.com
Documentation rationale
True jedi never comment their code Bullshit. Period. You can forget, what youd done one year ago. You can generate documentation from docstrings. Next developer will damn you, if you do not comment your code.
Documentation Sphinx
Documentation engine. Generates html, pdf and many more. Understands docstrings. # pip install sphinx > sphinx-quickstart
Questions?