Giter Club home page Giter Club logo

version-control-book's Introduction

Version Control Book {.unnumbered}

DOI DOI Quarto Publish All Contributors Codespell

Description {.unnumbered}

Welcome to the Version Control Book, a resource initially created in the context of a course on version control at Universität Hamburg in 2023/2024.

The Version Control Book aims to summarize all the relevant course contents for the students, effectively serving as a textbook for this course. The book also aims to serve as an open-source learning resource for everyone, with a particular emphasis on providing guidance for researchers learning version control using Git and GitHub. This is a living resource on why and - more importantly - how to use Git. The rendered version is at https://lennartwittkuhn.com/version-control-book/ and is under constant development.

Contributing {.unnumbered}

Contributions in any form - pull requests, issues, content requests, ideas, etc. - are always welcome. If you are using the book and find that something does not work, please let us know. You can find out more on how to contribute here, and a list of all contributors so far below. Before contributing, please read the guidelines for contributions on how to get involved. To maintain consistency and readability, we follow a style guide. Please refer to the Style Guide for details on formatting, coding standards, and other conventions. We appreciate your contributions and look forward to building a comprehensive and valuable resource on version control!

Usage {.unnumbered}

To render and preview, execute:

quarto preview

License {.unnumbered}

CC-BY-SA

You are free to

  • share - copy and redistribute the material in any medium or format
  • adapt - remix, transform, and build upon the material for any purpose, even commercially

under the following terms:

  1. Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

  2. ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

Contributors {.unnumbered}

Lennart Wittkuhn
Lennart Wittkuhn

🐛 💻 🖋 🎨 📖 💡 💵 🔍 🤔 🚇 🚧 🧑‍🏫 📆 💬 👀 📢
Konrad Pagenstedt
Konrad Pagenstedt

🐛 💻 🖋 🎨 📖 💡 🤔 🚧 👀
Yaroslav Halchenko
Yaroslav Halchenko

🐛 💻 🚇 👀

version-control-book's People

Contributors

lnnrtwttkhn avatar konradpa avatar yarikoptic avatar allcontributors[bot] avatar

Stargazers

Paul Gribble avatar  avatar  avatar Julian Kosciessa avatar

Watchers

 avatar  avatar

Forkers

yarikoptic

version-control-book's Issues

add resources

preparation of cli chapter

align the layout of the various chapters

  • move "acknowledgements" section to the bottom and rename to "acknowledgements & further reading"
  • move the cheatsheet to the bottom
  • "command-line" when used as an adjective, "command line" when used as a noun (see here)
  • "Git" instead of "git" throughout, see #37
  • add "prerequisites" to all the chapters, linking to previous chapters, as applicable
  • add {{< fa eye >}} to hidden outputs
  • add to beginning of chapter that readers are encouraged to type the command into the terminal instead of just reading.
  • add memes! students love memes!

add content

  • add a bit more "computer history" about the command line, making clear that this was for some time the main way to interact with a computer
  • add cc-by (or similar licensed) images of the CLI to the beginning of the chapter. maybe a GIF?
  • I think the difference between cli, terminal and shell is not yet super clear. maybe we can expand on this a bit. low-priority.
  • but based on that we should decide whether / when to use which term and clarify this explicitly
  • add instructions for mac, how to find out which OS version the computer runs
  • add juypterhub instructions for the terminal, ideally with screenshots
  • explain difference between bash and zsh

To verify if your machine is configured to use a shell other than Bash, you can type echo $SHELL in your Terminal window.

  • explain what the output of this ☝️ means
  • "navigating the file system": add more introduction text that explains how most users are familiar with navigating the file system through a GUI (e.g., Finder on Mac) using their mouse or arrows keys on the keyboard. we can do the same thing using the command line.
  • maybe add pictures that show what the same command or operation looks like in the finder
  • add explanation what is meant by "working directory"
  • add more explanation what hidden files are and why they are hidden
  • add a short warning that people should think about where they want to create new directories etc., e.g., on their Desktop and consider deleting it afterwards to not get confused.
  • add warning that files that are removed using rm are removed entirely and can not be retrieved from the bin! but please check that information again.

add to the terminology section

  • what is a "file"
  • what is a "folder"
  • what is a "directory"

general todos:

  • try out "git bash" on windows
  • explore jupyterhub
  • add recommendation to use tree command (see here) when viewing files and folders

Make urls in refs to be hyperlinks

ATM

image

may be there is an extension/option in the used system to automagically make them hyperlinks like github does?

❯ git grep -A5 '# References'
chapters/branches.qmd:# References
chapters/branches.qmd-
chapters/branches.qmd-https://www.atlassian.com/git/tutorials/using-branches
chapters/branches.qmd-
chapters/branches.qmd-https://lukemerrett.com/different-merge-types-in-git/
chapters/branches.qmd-
--
chapters/contributing.qmd:## References {#sec-references}
chapters/contributing.qmd-
chapters/contributing.qmd-- {{< fa book >}} ["Citations & Footnotes"](https://quarto.org/docs/authoring/footnotes-and-citations.html) in the Quarto documentation.
chapters/contributing.qmd-- {{< fa book >}} [HTML options for references](https://quarto.org/docs/reference/formats/html.html#references).
chapters/contributing.qmd-
chapters/contributing.qmd-### Cite a reference
--
chapters/datalad-nextcloud.qmd:### References
chapters/datalad-nextcloud.qmd-
chapters/datalad-nextcloud.qmd-- https://www.gwdg.de/storage-services/gwdg-owncloud
--
chapters/github-intro.qmd:## References
chapters/github-intro.qmd-https://www.gitkraken.com/learn/git/tutorials/what-is-a-pull-request-in-git
chapters/github-intro.qmd-
chapters/github-intro.qmd-https://the-turing-way.netlify.app/collaboration/github-novice/github-novice-features.html
chapters/github-intro.qmd-
chapters/github-intro.qmd-https://git-scm.com/book/de/v2/Git-Grundlagen-Mit-Remotes-arbeiten
--
chapters/installation-setup.qmd:# References 
chapters/installation-setup.qmd-
chapters/installation-setup.qmd-https://happygitwithr.com/ 
chapters/installation-setup.qmd-
chapters/installation-setup.qmd-https://swcarpentry.github.io/git-novice
chapters/installation-setup.qmd-
--
chapters/rewriting-history.qmd:## References
chapters/rewriting-history.qmd-
chapters/rewriting-history.qmd-- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository
--
chapters/stashing-rebasing.qmd:## References:
chapters/stashing-rebasing.qmd-
chapters/stashing-rebasing.qmd-https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning
chapters/stashing-rebasing.qmd-
chapters/stashing-rebasing.qmd-https://dev.to/_mohanmurali/deep-dive-into-git-rebase-5b05

notes for session 4

  • schedule: "git basics survey" shows up multiple times

  • permission denied when trying to init git repo with invalid path

  • git add -A or git add --a not git add -a

  • commit hash

preparation for session 4

  • play around with basic git commands, vim etc.
  • make multiple commits in one repository
  • compare commits across history
  • .gitignore
  • example use-case: tracking word documents in git
  • discussion: advantages / disadvantages of git in combination with binary files like word
  • relation to .gitignore: word create a temporary file, something like "~$mypaper.docx"
  • gateway to markdown session (session 5): why it's not great to track binary files in git and what are the alternatives to word
  • git commit : explain that one can also add a more detailed description, e.g., git commit -m "commit message" -m "longer description"
  • idea that one can use the description of the commit message to document changes in binary files in a bit more detail
  • discuss different workflows of using git add, git commit etc.
  • make minimal changes
  • encapsulate only neccessary changes in commit
  • reproducibility: recreate temporary files from changes in code
  • explain repeated --amend
  • add graphics that explain staging environment vs. commit

Add resources

notes re session 2

  • Add section on how to customize CLI visually (Mac: https://medium.com/@charlesdobson/how-to-customize-your-macos-terminal-7cce5823006e)
  • Student question: Explain difference between relative/absolute path
  • explain directory structure better.
    I have heard that especially today where students use their phones a lot it becomes less clear that a computer has a certain hierarchical directory structure
  • add echo command to CLI chapter
  • Student Question: Clarify: Where does cd ~/../../.. take you in file system?
  • Include using tab to autocomplete paths in command line
  • Clarify spacing between commands/flags
    -Student question: "can't access" when using wildcards to search for e.g. .yml files. Maybe change/clarify example?
  • re above: yes, use an example where they can actually use ls meanigfully
  • add "clear" command?
  • clarify what "-alh" output shows
  • Student question: "ls" doesn't have help flag (on Mac) ("man ls" works on Mac)
  • Using "q" to get out of page in terminal.
  • we should make the warning about rm -rf much bigger
  • add overview of directory and file structure
  • highlight folder structure differences between mac and windows
  • delete test results from survey
  • don't forget to make questions in survey optional

Notes for session 8

  • Switching to new branch only possible after first commit

  • using Crl/strg-c to get back to Terminal, getting out of "Quarto mode."

  • Uncommited changes switch to new branch

  • (Preparing) Demoing merge conflict

  • Visualizing differences between branches

  • Reference to git log (git log -all)

  • Showing merge conflict in GUI (GitKraken)

  • When is switching branches not possible?

Ideas for Session 9 (GitHub)

  • Layout
  • Decide on PAT or SSH for verification
  • @lnnrtwttkhn add SSH key section
  • 1. Pushing recipe repo to GitHub, 2. Creating repo on Github and clone it
  • Switching forking and cloning in book
  • Demoing cloning
  • Repository setting - add section in book (private/public, README)
  • Creating EMPTY repository to be able to push existing repo
  • Creating github organization?
  • Exercise: pushing existing repo to GitHub, clone it to different location on PC, make changes in clone, push changes, pull from original location
  • Extra Exercise: Create branch and push branch
  • Demo/Explain differences between git fetch and git pull
  • Put forking in end of book
  • Forking/Templaterepos/GitHub alternatives/Branch protection/git blame as extra content
  • Send email: Creating GitHub account
  • Session 10: Pull requests, collab, Github flow?
  • Figure out how to collaborate easily among course members - organization?
  • Section about GitHub flow?
  • Create slides

add more content

basic:
git fetch
git show
git blame
Hashes
git checkout to time/hash

commits:
detailed commit ettiquette
Repeating amends
interactive commits
git cherry-pick
git reset
git revert
git clean

advanced:
git archive
git bisect
git rev-parse
hooks
Mergetools

Notes for Session 9

  • Next Session - Zoom?

  • PAT: Explain Expiration date

  • PAT: Explain Scopes in detail

  • PAT: Explain Notes

  • Repository: Explain Public vs. Private

  • PAT: Multiple ways to when PAT has to be entered

  • Cloning: Maybe use repo of others not own?

  • Cloning same repo is maybe complicated

  • Pulling works only on branch that is pushed to GitHub

  • Session build on each other! -> make it more explicit

  • cheatsheet explizit erwähnen!. encourage use!

  • Emphasize use of git log/status to know about repo

  • emphasize cleaning up repos

  • Book: creating first repo without readme

  • checking branch you're on, before pulling

  • demo error: pulling while on "wrong" branch

minor change in branches chapter

If you want to keep your changes you should save them using the stage and commit workflow It is also possible to temporarily stash your changes using git stash or delete your changes using git reset which will both be covered in later chapters.

we should update the references to these chapters once they are in place.

notes for chapter on permissions and acess levels

--

Visibility and permissions settings on GitLab

  • GitLab (and GitHub) allow setting the project and group visibility
    • GitLab visibility levels: Private Internal Public (details here)
  • GitLab (and GitHub) allow setting fine-grained permissions and roles for contributors
    • GitLab roles: Guest Reporter Developer Maintainer Owner (details here)

--

Example workflow

  • Your projects are private from the start
  • Everyone in your group can view each other's projects (Guest or Reporter)
  • Direct collaborators (internal or external) can edit the project (Developer or Maintainer)
  • The PI gets access to all projects (Maintainer or Owner; optionally only at the end of a project)
  • Project can be set to public later on (e.g., upon publication)

???

  • Group members can always view your projects and their current status
  • Group members can clone your repository, fork it, open issues and merge requests
  • Group members can not make any changes to your project by default
  • PI has at least Maingtainer access to all projects for long-term availability

notes about gin + datalad

brief (incomplete) roadmap

  • I have a folder called "share"
  • I want to upload the data from the custer to gin
  • check how large the dataset is
  • modular datasets or one big dataset?
  • setup ssh
  • datalad save the dataset (use --force)
  • configure gin
  • push to gin
  • set up DOI

clarify differences between rebase and merge

when you do git pull one receives this

git pull
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint: 
hint:   git config pull.rebase false  # merge
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.

it would be good to clarify what to do in those circumstance.

add scientific use cases / translation to research workflow

I think it would be nice to add specific scientific use cases, where version control is particularly for scientific workflows.

a few examples that come to mind:

  • ethics applications
  • paper writing / feedback from supervisor
  • bug fixes in analysis pipelines

prepare for session 3: git basics

  • focus on vim (which is the default editor)
  • explain relationship between git, vim and other GUI text editors on the computer
  • explain the difference between plain text and Word
  • basics on how to use vim
  • discuss differences between local and global git config
  • explain to use same email for git and github
  • maybe skip account creation on github
  • clarify exercises for creating a recipe
  • .gitignore optional?
  • .gitignore discussion / ideas
    • keep repositories small / only commit files that are really needed
    • reproducibility: don't add files that can be easily regenerated from the committed code
    • don't add files that are not relevant to other users, e.g., editor configuration files etc.
  • differences between local and global .gitignore
  • add warning: don't create a new repo e.g., in your user directory
  • use ls -a command to show the hidden .git folder (add link to command line chapter)
  • add warning: don't mess with the .git folder
  • add git init my-project
  • add mini-quiz: how to create a project folder, either (1) mkdir my-project && cd my-project & git init or git init my-project
  • setup session as live coding session
  • separate installation and setup chapter
  • move creation of github account to github chapter
  • edit installation and setup survey
  • send email to ask to verify installation and complete installation survey
  • git commands always refer to the "closest" .git file. clarify that.
  • beware of nested .git repositories. explain if it's possible to have nested git repositories
  • decide for default text editors on Windows (Notepad) and macOS (TextEdit)
  • demonstrate interaction between editing text files in vim and through the GUI texteditor
  • explain what the staging area is, see e.g., https://youtu.be/HMqUFlu0gFc?t=228
  • think about whether to add STOP signs to the chapter for course participants!

notes for session 3

  • CLI Survey: clarify question about using dashes for flags
  • Question: How to show only specific configurations
  • Clarify what plain textfiles are
  • Clarify Vim (hard to do), creating file with vim
  • cat command
  • combining vim commands
  • Content is not important, does not have to be recipes, can also initialize existing code
  • CLI: creating subfolders with mkdir -p
  • Git commands apply in git initiliazed-parent director if used in child directory
  • Problem: little bit too much content for session, had to rush at the end
  • Add using semilicons to combine commands (maybe in CLI chapter)

add gitlab functions for issues

these are two gitlab functions in issues that AFAIK do not exist on github:

Confidential issues in GitLab

  • Confidentiality: Issue visible only for team members

Due dates in Gitlab

  • Due date: Set due dates for Issues

Keeping this here for later, if we still want to add it.

branches chapter rendering is odd

github actions crashes

adding:

engine: knitr
execute:
  eval: false

to the yaml header, fixes it. but this is not necessary for all other chapters.

weird, but I will apply this as a hotfix

add resources

add chapter on "good" commits

  • what is a "good" commit
  • reduce diffs
  • atomic commits / which level of granularity
  • what are good commit messages
  • when to branch / how to branch
  • link commits to issues

notes for chapter on pull request

.pull-left[

Basic collaboration workflow:

  1. Clone the repository (i.e., "download the project")
  2. Switch to a new branch (i.e., "start a separate version")
  3. Make changes to the files and push the new version
  4. Open a merge / pull request 1
    {{content}}
    ]

--

The repository maintainer (i.e., you) can ...

  • see what was changed when by whom
  • add additional changes to the merge request
  • run (automated) checks on the contribution
  • approve the contribution and merge the changes
    {{content}}

--

Examples:

  • A co-author proposes changes to your manuscript
  • A collaborator adds new data to your dataset
  • A colleague fixes several bugs in your analysis pipeline

dumping ideas

sorry, this is not very elegant but I'm quickly dumping a few notes heres:

  • "recipes task": (1) add your favorite recipes, (2) add a recipe that you don't like /this will be removed later)
  • .gitignore: explain the difference between global and project-specific .gitignore
  • .gitignore: explain what .DS_Store is (for mac users only)
  • add more categories to the chapters so they show up in the contents page
  • labels for difficulty / experience level: beginner, intermediate, advanced
  • create one page with all the cheatsheets

@konradpa, could you please review these points and let me know what is already included in the book and what we still could add? let me know if anything is unclear! thanks!

add contributing page

  • how to make changes to the project
  • how to use quarto
  • add software and requirements details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.