Course materials · Robot Basic Lab

GitHub collaboration

English translation

Use a safe local example to learn how to combine changes without losing them when several people edit the same file.

Before practice

01 What do commits and branches store?

Description

A commit is a point in the change history; a branch is a name pointing to that history.

02 Why is automatic merging difficult when the same line is changed differently?

Description

Git cannot choose between different intentions, so a person must decide the desired final content.

Execution conditions

The baseline exercise uses a temporary local Git repository. You can explore changes, branches, and merges without a GitHub account or a remote repository connection.

Practice

Preview practice notebookDownload practice notebook

1. Track changes to one file

Starting conditions

repo is temporary storage on the computer running the notebook kernel. In README.md inside it, change Condition: baseline to Condition: test.

Procedure

  1. After checking the baseline commit, read repo/'README.md' in a new code cell in the same notebook, change only the specified sentence, and save. Resolve file paths relative to repo.
  2. Call the provided git(*args) function in a code cell and record the diff and status. For example, you can display changes with print(git('diff')).
  3. Commit the changes, then check the difference from the previous commit again.

Results to retain

Items to record and points to check
Step
File contents
Working tree status
Commit message

Points to check

  • Are file changes distinguished from committed history?
  • Does the record contain no passwords or tokens?

2. Separate experimental conditions with branches

Starting conditions

Create an experiment branch in the same repository and add Rate: 10 Hz to README.md.

Procedure

  1. After committing on experiment, return to main and compare the file contents.
  2. Inspect both branches' histories with log --oneline --all --graph.
  3. After merging into main, describe what remains in the file and history.

Results to retain

Items to record and points to check
Branch and step
README contents
HEAD Commit
Location of the change

Points to check

  • Is the working tree clean before switching branches?
  • Did you actually read the main file before and after merging?

3. Reproduce and resolve a conflict

Starting conditions

Change the same Condition line to different values on main and experiment, and commit each change.

Procedure

  1. Attempt the merge and keep the file containing conflict markers.
  2. Resolve the conflict by writing the final selected condition on one line, then commit.
  3. Explain the difference between editing different lines and editing the same line.

Results to retain

Items to record and points to check
Scenario
Merge result
Selected final sentence
Reason for selection

Points to check

  • Are the conflict markers <<<<<<<, =======, and >>>>>>> absent from the final file?
  • Is git status clean after resolution?