Week 3̷4- Office Hours

Part 1 - Rebasing

  1. git log --graph --oneline

  2. Open the terminal in the folder with the repository you used for the homework.

  3. Run gh browse and add a line to week-3.txt, commit changes.

  4. Add a line to "week-3.txt" locally, stage, commit.

  5. git push. What is the problem?

  6. Download data from GitHub without pulling.

  7. What was the alternative to git merge in the homework? Do that.

  8. Resolve the conflict in the editor.

  9. Tell what git status suggests and then what the error message suggests in order to finish the rebase, then push to GitHub.

  10. git log --graph --oneline How do the two conflict situations differ?

Part 2

This week, we'll discuss the meaning of the following terms:

  • Commit.

  • Staging (aka Adding).

  • Committing.

  • Folder Tree, Repository Root.

  • Working Tree.

  • Staging Area (aka Index).

  • HEAD.

  • Repository (aka Repo).

Git command anatomy

We'll talk about what individual pieces of a git command represent.

Undoing in git

One of the points of version-controlling code and text is to be able to undo mistakes. We'll see different versions of how this can be done.

Prepare files and folders

Go to this link, download the files as an archive (click Code -> Download Zip), unzip it into the folder where you keep everything related to this course.

We could have done a git clone instead but it is useful to know that you can just download the files if you need to.

If you only have a single folder with one of the repos you created earlier then create a new folder, and put both the repo folder and the folder with the unzipped files. Here is what the folder structure should look like:

git-course/
├── my-repo-1/
│   └── ...
├── my-repo-2/
│   └── ...
└── week-4-files/
    └── ...

The names of the folders and the exact structure isn't important. The main thing to avoid is this:

  my-repo-1
    week-3-files
      ...
    ...

Follow along

Folder tree, root

Go to the git-course folder and run tree . in the Terminal.

Repository root

mkdir week-3-repo
cd week-3-repo
git init
ls
ls -a
git status

Commits, staging, head

<copy week-3-files/README.md>
git status
git add -- README.md
git status
git commit -m "add README.md"
git status
<copy week-3-files/01_data/ to .>
git add .  # don't do it! at least not without git status first
git status
git rm --staged .  # that's the opposite of git add for new files
git add . -v  # better but should still be avoided
rm 01_data/02_derivatives/analyzed_data.csv
git rm --staged -- 01_data/02_derivatives/analyzed_data.csv
git commit -m "add raw data"

Last updated