Git & GitHub
Workshop
Kazuharu Yanagimoto
September 23, 2022
take logs of all coding activity of you and your collaborators
go back to a previous version of codes
focus on the change in the codes, and detect bugs
separate things completed and under development
.git
will be made.git
folder.git
folder in your local machine (like in the previous page) is called local repositoryFor now, forget about origin main
git clone URL_OF_REPOSITORY
git branch BRANCH_NAME
git switch BRANCH_NAME
git merge BRANCH_NAME
A simple suggestion is main-dev workflow
I merge into main just before the meeting with my supervisor or collaborators.
A different code is written in the same line of two branches in merging
Most conflicts can be avoided by a rule prohibitting members from co-editting the same file
origin/BRANCH_NAME
git pull origin main
is equivalent to git fetch origin main && git merge origin/main
git pull
could return a CONFLICT!foo1.txt
with a line of text (e.g. “Tortilla sin Cebolla”) and create a commitfoo1.txt
with a line of different text (e.g. “Tortilla con Cebolla”) and a create a commitfoo2.txt
with a line of text (e.g. “But the Emperor has nothing at all on!”). Push it into origin/devfoo2.txt
with a line of different text (e.g. “Oh! How beautiful are our Emperor’s new clothes!”). Push it into origin/mainfoo3.txt
with a line of text (e.g. “Mountain of Mushroom”), create a commit, and push into origin/devfoo3.txt
with a different line of text (e.g. “Village of Bamboo Shoot”), create a commitOr
If you want to stage all modified files, git add .
I recommend you to delete the remote and local dev branch here.
.gitignore
?data/
) and by extension (e.g. *.csv
)*.dvc
) for the meta-information of the data.gitignore
).dvc/cache
with a random (hashed) nameYou can specify a folder (e.g. data) with -R option
For the first push (or pull), you will see an authentication URL.
data/csv
folder and create a commit (say, “add foo1.csv”)You can see all the git activity (commit, merge, rebase, …)
You can reset any git activity
Introduction to Git・ Introduction to GitHub