Two people, one line
Ana and Ben work on the same file. Both add a name at the end of the same list.
Ana finishes first. Then Ben tries to join his work to hers. Whose line should win?
Git does not guess. It stops and asks a person. Today you are that person.
Key words
| Word | What it means | Example |
|---|---|---|
| Conflict | Two changes to the same place that Git cannot join by itself. | Two names on the same line |
| Merge | Bring the changes of one branch into another. | git merge ben |
| Branch | A separate line of work. | ben |
| Commit | One saved step in the history. | Add Ben |
| Merge commit | A commit that joins two lines of work. | Merge branch ben |
| Conflict markers | Lines Git writes in the file to show both versions. | <<<<<<< and >>>>>>> |
| Resolve | Choose what the file should say, and save it. | Keep both names |
| Repository | A folder of files with all its history. | hello-git |
| Stage | Choose which changes go into the next commit. | git add visitors.txt |
| Clone | Make your own copy of a repository. | git clone ... team |
The cells students fill in are left blank in this preview.
Start the lab first
data-callouts.note.label
Press Start the lab on the bar at the top of this lesson. Wait until it says it is running. You work in a new folder, so this lesson does not need the earlier one.
1. A fresh copy
First tell Git your name and email. Then clone the project (make your own copy) into a new folder called team. Then go into the folder.
git config --global user.name "Student"A command for the lesson’s lab terminal. It is shown here and not run.
git config --global user.email "[email protected]"A command for the lesson’s lab terminal. It is shown here and not run.
git clone http://student:student@gitea:3000/student/hello-git.git teamA command for the lesson’s lab terminal. It is shown here and not run.
cd teamA command for the lesson’s lab terminal. It is shown here and not run.
2. Ben works on a branch
You play both people. First you are Ben. Make a branch, add a line, and commit. The -a in commit -am means: stage all changes to files that Git already knows. The -m gives the message.
git switch -c benA command for the lesson’s lab terminal. It is shown here and not run.
echo "Ben" >> visitors.txtA command for the lesson’s lab terminal. It is shown here and not run.
git commit -am "Add Ben to the visitors list"A command for the lesson’s lab terminal. It is shown here and not run.