Hannes Datta
Part 2: Git - work locally (“workflow”)
Coaching session
After class: complete tutorial + review command line/terminal (e.g., Datacamp, Mac & Windows; Mac Tutorial)
README.md
)git init
)readme.md
to “First repository with exercises in dPrep” & commit your changes on GitHub.comGit on your own computer for actual coding and file versioning
GitHub.com for interactive web interface and project management
We first proceed with the interactive interface on GitHub.com.
Note: I will have to make you members of the organization for this to work… (let's see - otherwise we move up until after the break)
We now start with the project board. Afterwards, we talk about issues.
Task:
When finished, you should have an empty board with four columns (you may want to change to card view).
Open a new issue
Assignment
Tip: For now, let's say you need to add the motivation of your project to the readme.
Overview available at https://dprep.hannesdatta.com/docs/project/resources/cheat-sheets/
I'll first demonstrate it on one of my own repositories. You can then repeat these steps on your own repository.
You iterate between the following stages.
1) Team meeting (“scrum meeting”)
2) Individual work
Meet again with your team.
Repeat workflow until you're done (or the deadline has passed…)
git clone
repository to which you have access to (once)git pull
to update from the cloud (before starting to work)git status
, git add
, git commit -m "message"
(multiple times)git push
to push changes to cloud (after finishing work)1.) Copy the URL to your class room repository
2.) Open Git Bash, and type
git clone https://github.com/course-dprep/XXXXXXX
(REPLACE XXXXXXX with the name of your repository, which you find in the URL of your browser)
3.) Check whether you see your repository on your computer (e.g., Windows Explorer)
Got an error? (“Support for password authentication was removed on August 13, 2021”) → Check how to fix it here.
Once the repos is available locally, we can “work” in it.
While doing so, we make “commits” (we save code in our unlimited version history)
We can do so on different branches - each issue has its own development branch
You next learn how to do all of this.
gh pull XXXX
)git status
)git status
(view changes)git add <filename>
(add file(s) to “staging area”)git commit -m "message"
(freeze commit)git push
(push to GitHub; sometimes also git push -u origin branch_name
)master
/main
branch holds your working version of your project.hannes-123
, but named by a featuregit branch -l
to see which branches existgit branch <new_branch>
create a new branch namegit fetch
or git fetch --all
to “update” all branches from cloudgit checkout <branchname>
or git switch <branchname>
to switch (back and forth)feature
(git branch feature
)git switch feature
)main
branch.When new changes become available (online) at a branch, you can integrate them using “pull requests”.
It's good practice to assign reviewers to new pull requests.
git log
)
git checkout <commithash> filename
(will overwrite old file)git checkout filename
(Alternatively, use: git show <commithash>:filename > old_filename
) to get the old file as a second file.)
main
branch (vs.: we work in one synchronized folder in the cloud)rfile-hannes1.R
)git checkout
, git pull
, git status
, git add
, git commit
, git push
course-dprep
organization)How to Start: