Skip to content

biosustain/git-tutorial

 
 

Repository files navigation

Git Tutorial using

VS Code on Binder
VS Code on Binder, because sometimes you need a real editor.

PyPI Install with conda

Start:

  • lab: Binder
  • vscode: Binder

Explore

You will need to setup your git email and user-name (replace with yours in case you want to commit something, otherwise use copy-paste)

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

could be added to local config using git config user...

Steps

  • create a folder with an empty repository (default examples directly openend in VSCode on binder)
  • open instruction: code-server ../README.md (local computer: code ../README.md)
  • git init in console to initialize repo (or via command palette "Git: Initialize Repository")
  • setup user.name and user.email (see above)
  • create files, stage them and see what files are created in .git/objects
  • commit files and check .git/objects
  • create branches and checkout .git/refs (git/branches is a legacy folder,see here)
  • look at git/HEAD (maybe git/ORIG_HEAD if it exists)

try to create your own fork, and try to lauch it on mybinder

You can find a recording of the talk (slides) and hands-on tutorial on YouTube which was done for the Data Club seminar between DTU biosustain and DTU bioengineering (see sections in description of Video).

Talk: Recording of talk

Live Demo: Live Demo of Hands On part

The above Live Demo is not pulling the merge commit after merging the branch on GitHub: github.com/biosustain/git_training_henry_recording

I show the merge commit in the video below, cloining the recording repository in a newly create VSCode sandbox environment above:

Live Demo Hand on Addon

Links

Inspect git objects

git log --format=raw
git cat-file -p <hash> # pretty print
git cat-file -t <hash> # type

# the binary object can also be inspected using different tools,
# which might make it easier to navigate to certain blobs:
cat .git/objects/<2c>/<38c> | zlib-flate -uncompress

You can find the latest objects and compare it to the log

find .git/objects  -type f -exec ls -lt {} + | head -n 10
git log --format=raw -n 3

If you wonder what the codes in a tree mean, check this stackexchange answer

What's happening?

  • You commited ten commits and dit not yet push. Git complains about too much data. You realize that you commited your source data. You delete it and commit again, but the problem still persists.
  • You commit something and push. You realize your last commit was wrong. You undo it and commit again. Git complains that you cannot push.

Releases

No releases published

Packages

No packages published

Languages

  • Python 83.6%
  • Shell 16.4%