theme | highlighter | lineNumbers | title | info | drawings | download | exportFilename | selectable | aspectRatio | presenter | transition | colorSchema | class | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eloc |
prism |
false |
Intro to Git |
## Git intro
|
|
true |
intro-to-git |
true |
16/9 |
dev |
fade |
light |
text-center |
collaboration
reproducibility
backups
software
writing
citations
<style> h2 { @apply absolute top-5 text-center; } </style>
- commits: a snapshot of your files*
- commit graph: commits are organized into a directed acyclic graph
*if git is tracking the files
git clone
git add
git commit
git push
git pull
git status
git log
modified
staged
committed
- staging changes:
git add <files>
- viewing the index:
git status
git commit
- only changes in the staging area are added to the commit
- commits need a commit message
- working tree staging area:
git diff
- staging area HEAD (the parent commit):
git diff --staged
- modify the contents of your
README.md
file - stage those changes (
git add
) - commit the changes (
git commit
)
git log
- create a new file:
test.md
- write stuff in
test.md
- add
test.md
to the staging area - commit your changes
- you complete a logical, atomic unit of work
- you might want to undo those changes
oops!
git revert
- revert your first commit
local vs. remote repositories
- verify that your local branch is ahead of the remote
git status
- push your local changes to the GitHub repository (remote)
- edit a file and make a commit using your repo's GitHub webpage
- pull those changes into your local repo
a commit by any other name...
git tag -a v0.1
- tag your most recent commit as
v1.0
<style> .slidev-vclick-target { transition: none; } </style>
- create branch:
git branch <branch-name>
- change current branch:
git switch <branch-name>
- create a branch called
cool-feature
and switch to it - add
hello from cool-feature branch
to yourREADME.md
git merge <branch-to-merge>
- need to be in the branch you want to merge into
- switch to your
main
branch - merge
cool-feature
intomain
gitGraph:
commit
commit
commit
branch feature1
checkout feature1
commit
commit
checkout main
merge feature1
commit tag: "v1.0.0"
branch feature2
commit
commit
checkout feature2
commit
commit
commit
checkout main
commit "v.1.1.0"
branch feature3
checkout feature3
commit
commit
checkout main
merge feature3 tag: "v1.2.0"
checkout feature2
commit
checkout main
merge feature2
commit tag: "v2.0.0"
Archiving code with Zenodo
assign DOIs to your code
Playground: https://git-school.github.io/visualizing-git
<iframe src="https://git-school.github.io/visualizing-git" title="https://git-school.github.io/visualizing-git"></iframe>