# [Version Control with Git Workshop Page](https://imageomics.github.io/2024-08-16-osu-online/)
**Instructors**:
- Matthew Thompson, PhD
- Elizabeth Campolongo, PhD
[Code of Conduct](https://docs.carpentries.org/topic_folders/policies/code-of-conduct.html)
---
## Topics to cover
**Navigating the Shell** (45m)
• Introducing the Shell
• Navigating Files and Directories
**Version Control with Git: Command Line** (70m)
• Automated Version Control
• Setting Up Git
• Creating a Repository
• Tracking Changes
• Exploring History
• Ignoring Things
**Version Control with Git: Remotes** (65)
• Remotes in GitHub
• Collaborating
• Conflicts
• Open Science
• Citation
## Follow-up Links
Follow up links:
- [github ssh instructions](https://docs.github.com/en/authentication/connecting-to-github-with-ssh)
- Carpentries [image conflicts example](https://swcarpentry.github.io/git-novice/instructor/09-conflict.html#conflicts-on-non-textual-files)
- [GitHub Projects](https://docs.github.com/en/issues/planning-and-tracking-with-projects/learning-about-projects/about-projects) are particularly useful for relegating and tracking tasks within GitHub.
- Be sure to add a license to your repo, for information on options see [choosealicense.com](https://choosealicense.com/) or consult with your instution's copyright people.
- [CITATION.CFF](https://citation-file-format.github.io/): tell end-users or people building off your work how to cite it.
## Schedule
| Time | Content | Instructor |
| -------- | -------- | -------- |
| 9:00-9:20 am | Course intro and logistics | |
| 9:20-10:05 am | Navigating the Shell | Matt |
| 10:05-10:20 am | Break | |
| 10:20-11:30 am | Version Control with Git: Command Line | Matt |
| 11:30 am-12:30 pm | Lunch | |
| 12:30-1:50 pm | Version Control with Git: Remotes | Elizabeth |
## Course intro and logistics
## Navigating the Shell
### Running Commands
Open bash/zsh shell
`ls` -- list contents of current folder
`pwd` -- print working directory: full absolute path to current location
ex on Mac: `/Users/campolongo.4/documents/GitHub/git_training/aug-2024`
`ls -F` -- same as `ls` on Windows, but on MAC will indicate folders and other types (e.g., adds the `/` at the end)
`ls --help` or `man ls`
* `man ls` takes you to "page mode". Type `q` to quit
`clear` -- empties shell output
`cd ~` -- shortcut to home directory
`pwd`
`ls -F Desktop` -- shows content of "Desktop" folder without entering it
`cd shell-less-data` -- navigating to non-existent folder (bash/zsh tells you "No such file or directory")
`cd Desktop` -- change directory to Desktop
`cd Videos` -- since we're in Desktop, Videos is not in our path, so we can't enter
`cd ..` -- go up one level (to parent directory)
`cd Videos` -- enter Videos folder
`cd ~`
`ls -a` or `ls --all` -- prints all files and folders (including hidden files such as `.DS_Store`)
`ls --help`
Tab auto-complete:
* `pwd`
* `ls Des` "tab" to get Desktop (note, some systems will not be case sensitive)
* `ls D` tab twice, quickly -- list contents starting with "D"
`cd /` -- go to root of file system
`ls`
`cd -` -- go to last directory you were in
`clear` -- to clean shell
`cd ~`
`pwd`
`mkdir thesis` -- make a directory called thesis
`cd thesis`
`pwd`
`ls` -- nothing yet!
`mkdir -p ../project/data ../project/results` -- make new directories in parent directory: project with data and results inside it
* the `-p` tells it to create any needed parent directories
`mkdir ../project/data/experiment1/sample1` -- fails with non-existent `experiment1` folder
"up arrow" -- gives last command, which is editable (add the -p):
`mkdir -p ../project/data/experiment1/sample1`
* caution with `-p`, if you expect a directory to be there, don't use it
`ls -F ../project`
* shows: `data/` and `results/`
`ls -F -R ../project` -- shows contents of the requested folder and all it's contents recursively, so shows the experiment1 folder and its contents as well.
`ls -FR ../project` or `ls -RF ../project` will do the same as `ls -F -R ../project`
**Note:** best practie to keep directory names alpha-numeric with `_` or `-` or `.`, allows for easier navigation in the shell. If a folder has a space in the name, then you must use quotes to contain it (e.g., `cd "My Project"`)
`cd ~/thesis`
`nano draft.txt` -- brings us to editor (`nano` opens the file "draft.txt")
* "It's not publish or perish any more."
* "It's share and thrive."
* See commands along bottom: ^ = control `^O` to save, can rename or stick with same name, then `^X` to exit
`ls`
`rm draft_1.txt` -- delete draft_1.txt, careful with this!
`ls`
`rm ~/project` -- does not allow you to remove the folder
`rm -r ~/project` -- delete the directory recursively (deletes folder and its contents) <-- USE WITH EXTREME CAUTION
`rm -r .` -- will not let you delete everything
`cd ..`
`rm -r thesis` -- delete the folder we created (though there are no contents now)
`rmdir thesis` -- deletes just the directory
`touch thesis.txt` -- creates thesis.txt file with no contents
`mkdir thesis` -- creates thesis directory
`touch thesis/draft.txt` -- puts empty draft.txt file inside thesis directory
`rm th` Tab auto-complete to `rm thesis.txt`
`rm -r thesis` -- clean up (remove) directory
## VC with Git: Command Line
### Running Commands
open your bash/zsh shell
format: `git <verb> <option>`
`git --help` or `git -h` -- provides help (flags and what they do)
* bracket with line between them (x | y) means use x or y to do the same thing
#### Configuration:
`git config --global user.name "<your name here>"` -- sets name associated with your commits across your computer
`git config --global user.email "<your email here>"` -- sets email associated with your commits across your computer
* online, git allows you to have this anonymized (setting in the account)
End of line configuration:
Linux or Mac:
`git config --global core.autocrlf input`
Windows:
`git config --global core.autocrlf true`
Preferred text editor configuration (this is within terminal/shell for things like merge conflict fixing or rebases):
`git config --global core.editor "nano -w"`
Set default branch name as `main`:
`git config --global init.defaultBranch main`
* sometimes `master` is used, but `main` is the conventional choice.
` git config --global --edit` -- editable review of git configs
`ctrl-X` to exit
`git config --list` to just view your configuration settings
`clear` to clean up terminal/shell window
#### Creating a Repository (Repo)
`cd ~/Desktop/`
`mkdir planets`
`cd planets`
```
git init
Initialized empty Git repository in /<path>/planets/.git/
```
`ls`
`ls --all` or `ls -a`
shows: `. .. .git`
`ls .git`
`ls -F .git`
shows:
```console
HEAD description info/ refs/
config hooks/ objects/
```
`git checkout -b main` -- make and "checkout" new branch `main`
`git status` -- tracking local changes:
```
On branch main
No commits yet
nothing to commit (create/copy files and use "git add" to track)
```
`cd ~/Desktop/planets`
`mkdir moons && cd moons` -- make directory moons and go into it
`git init` -- initializes new git repo in this directory (not necessary, and can actually be problematic)
Fix:
* `cd .. ` or absolute path to planet
* `ls` -- should show moons
* `rm -rf moons/.git` -- VERY DESTRUCTIVE, no warning. This will force remove the `.git` folder from `moons` so that it is no longer a repo inside a repo
* `ls -a moons`, should be empty now with just the `./` and `../`
`cd ~`
`git status` --not a git repo
`cd Desktop/planets/moons`
`git status` --now we have status message (same as above) that we're on branch `main` in repo
`cd ..` ---should put you in `planets` (make sure you're in `planets` now)
`nano mars.txt`
* Cold and dry, but everything is my favorite color.
* ctrl-O
* enter
* ctrl-x
`ls`
`cat mars.txt`:
```console
Cold and dry, but everything is my favorite color.
```
`git status`:
```console
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
mars.txt
nothing added to commit but untracked files present (use "git add" to track)
```
Stage the new file for commit:
`git add mars.txt`
Check status again:
```console
git status
# PRINTS:
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: mars.txt
```
Now we will commit this change with informative message:
`git commit -m "Start notes on Mars as a base"`
output:
```
[main (root-commit) 1a3c510] Start notes on Mars as a base
1 file changed, 2 insertions(+)
create mode 100644 mars.txt
```
* commit should focus on _why_, the _what_ can be seen through a `git diff` (by looking at changes)
Check status again:
```console
git status
# PRINTS:
On branch main
nothing to commit, working tree clean
```
`git log`:
```console
commit 1a3c510b7ed0f79f8e7d39a118ec3da946ec61dc (HEAD -> main)
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 10:56:56 2024 -0400
Start notes on Mars as a base
```
`nano mars.txt`
* type: The two moons may be a problem for Wolfman.
* ctrl+o enter
* ctrl+x enter
check status:
```console
git status
# PRINTS:
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: mars.txt
no changes added to commit (use "git add" and/or "git commit -a")
```
`git diff` -- show changes:
```console
diff --git a/mars.txt b/mars.txt
index b873b62..42d92e3 100644
--- a/mars.txt
+++ b/mars.txt
@@ -1,2 +1,2 @@
Cold and dry, but everything is my favorite color.
-
+The two moons may be a problem for Wolfman.
```
`git add mars.txt`
`git commit -m "Note Wolfman's concern about moons"`
(recall: up arrow gives last command)
`nano mars.txt`, type:
`But the Mummy will appreciate the lack of humidity.`
* ctrl+o enter
* ctrl+x enter
`git diff` prints:
```console
diff --git a/mars.txt b/mars.txt
index 42d92e3..2a282ee 100644
--- a/mars.txt
+++ b/mars.txt
@@ -1,2 +1,3 @@
Cold and dry, but everything is my favorite color.
The two moons may be a problem for Wolfman.
+But the Mummy will appreciate the lack of humidity.
```
`git add mars.txt`
`git diff` --prints nothing. Just compares current working directory and staging area
`git diff --staged` to get difference once added:
```console
diff --git a/mars.txt b/mars.txt
index 42d92e3..2a282ee 100644
--- a/mars.txt
+++ b/mars.txt
@@ -1,2 +1,3 @@
Cold and dry, but everything is my favorite color.
The two moons may be a problem for Wolfman.
+But the Mummy will appreciate the lack of humidity.
```
`git commit -m "Discuss concerns about Mars' climate for Mummy"`
`git status` --check status again (working tree clean)
Now, look at log:
```console
git log
commit d1637629f7346c66a86138453a9d69e230e82bed (HEAD -> main)
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 11:06:33 2024 -0400
Discuss concerns about Mars' climate for Mummy
commit 9ebad97d1045521f4240623544052b28eb3b8cd9
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 11:02:31 2024 -0400
Note Wolfman's concern about moons
commit 1a3c510b7ed0f79f8e7d39a118ec3da946ec61dc
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 10:56:56 2024 -0400
Start notes on Mars as a base
```
`git log --help` --webpage for windows, for mac it's in the terminal `q` to exit
`git log -1` shows last line
`git log --oneline`:
```console
d163762 (HEAD -> main) Discuss concerns about Mars' climate for Mummy
9ebad97 Note Wolfman's concern about moons
1a3c510 Start notes on Mars as a base
```
When you have multiple branches, graph can be helpful:
```console
git log --graph
# PRINTS:
* commit d1637629f7346c66a86138453a9d69e230e82bed (HEAD -> main)
| Author: egrace479 <e.campolongo479@gmail.com>
| Date: Fri Aug 16 11:06:33 2024 -0400
|
| Discuss concerns about Mars' climate for Mummy
|
* commit 9ebad97d1045521f4240623544052b28eb3b8cd9
| Author: egrace479 <e.campolongo479@gmail.com>
| Date: Fri Aug 16 11:02:31 2024 -0400
|
| Note Wolfman's concern about moons
|
* commit 1a3c510b7ed0f79f8e7d39a118ec3da946ec61dc
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 10:56:56 2024 -0400
Start notes on Mars as a base
```
These can be combined
* ex: `git log --oneline --graph`
`git log -p` : shows diffs for each commit in log, use arrow keys to scroll
* Scroll or use up and down arrows to navigate.
* Press `Spacebar` to jump down a page
* Search for a word with `/`
* Go to the next result with N and previous with Shift + N
* Presse h to see all the commands available when using the pager.
* Press Q to exit.
* You can also get diff info within a line with the `--color-words` option of `git diff`
`cd ..`
`cd planets`
`mkdir spaceships`
check status:
```console
nothing to commit, working tree clean
(base) planets % git add spaceships
(base) planets % git status
On branch main
nothing to commit, working tree clean
```
git won't recognize empty directory, so add placeholder file:
`touch spaceships/.placeholder`
check status:
```console
git status
# PRINTS:
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
spaceships/
nothing added to commit but untracked files present (use "git add" to track)
```
`rm spaceships/.placeholder`
`touch spaceships/apollo-11 spaceships/sputnik-1`
* if you added them outside spaceships: `mv apollo-11 spaceships/` and `mv sputnik-1 spaceships/`
* general command: `mv <source> <target>`
```console
git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
spaceships/
nothing added to commit but untracked files present (use "git add" to track)
```
`git add spaceships`
```console
git commit -m "Add initial thoughts on spaceships"
[main 70a34e0] Add initial thoughts on spaceships
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 spaceships/apollo-11
create mode 100644 spaceships/sputnik-1
```
`clear` to clean up terminal/shell
can reference commits by their hash, the last commit can be referenced by `HEAD`
`nano mars.txt`
`A bad change.`
`git diff`
`git diff HEAD mars.txt` will show same change as git diff here.
`git diff HEAD~3 mars.txt` shows diff from three back:
```console
diff --git a/mars.txt b/mars.txt
index b873b62..bad0bac 100644
--- a/mars.txt
+++ b/mars.txt
@@ -1,2 +1,5 @@
Cold and dry, but everything is my favorite color.
+The two moons may be a problem for Wolfman.
+But the Mummy will appreciate the lack of humidity.
+A bad change.
```
`git show HEAD~3 mars.txt` --shows what diff would have shown then:
```console
commit 1a3c510b7ed0f79f8e7d39a118ec3da946ec61dc
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 10:56:56 2024 -0400
Start notes on Mars as a base
diff --git a/mars.txt b/mars.txt
new file mode 100644
index 0000000..b873b62
--- /dev/null
+++ b/mars.txt
@@ -0,0 +1,2 @@
+Cold and dry, but everything is my favorite color.
+
```
`git log` to see changes ---copy your second down commit has there (d163 for this):
```console
commit 70a34e056cc4f2cf12c76ccf3d148f35544ab1e9 (HEAD -> main)
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 11:18:46 2024 -0400
Add initial thoughts on spaceships
commit d1637629f7346c66a86138453a9d69e230e82bed
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 11:06:33 2024 -0400
Discuss concerns about Mars' climate for Mummy
commit 9ebad97d1045521f4240623544052b28eb3b8cd9
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 11:02:31 2024 -0400
Note Wolfman's concern about moons
commit 1a3c510b7ed0f79f8e7d39a118ec3da946ec61dc
Author: egrace479 <e.campolongo479@gmail.com>
Date: Fri Aug 16 10:56:56 2024 -0400
Start notes on Mars as a base
```
```console
git diff d1637629f7346c66a86138453a9d69e230e82bed mars.txt
diff --git a/mars.txt b/mars.txt
index 2a282ee..bad0bac 100644
--- a/mars.txt
+++ b/mars.txt
@@ -1,3 +1,5 @@
Cold and dry, but everything is my favorite color.
The two moons may be a problem for Wolfman.
But the Mummy will appreciate the lack of humidity.
+
+A bad change.
```
can also use shortened hash from `git log --oneline`
`git status`:
```console
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: mars.txt
no changes added to commit (use "git add" and/or "git commit -a")
```
`git checkout HEAD mars.txt` goes back one commit: `Updated 1 path from 6fd06c9` ---discards the bad change, can't go back though
`git log --oneline`:
```console
70a34e0 (HEAD -> main) Add initial thoughts on spaceships
d163762 Discuss concerns about Mars' climate for Mummy
9ebad97 Note Wolfman's concern about moons
1a3c510 Start notes on Mars as a base
```
`cat mars.txt`
```console
Cold and dry, but everything is my favorite color.
The two moons may be a problem for Wolfman.
But the Mummy will appreciate the lack of humidity.
(base) planets % git add mars.txt
(base) planets % git status
On branch main
nothing to commit, working tree clean
(base) planets % git commit -m "go back in time"
On branch main
nothing to commit, working tree clean
```
`git checkout main` to return to safety in case of detatched HEAD state.
#### Ignoring things
Macs tend to have `.DS_Store` files added that you don't want to track (you may also find cache files, etc)
`mkdir results`
`touch a.dat b.dat c.dat results/a.out results/b.out`
```console
git status
#PRINTS:
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
a.dat
b.dat
c.dat
results/
nothing added to commit but untracked files present (use "git add" to track)
```
`nano .gitignore`
* type: *.dat
* results/
```console
git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
```
`git add .gitignore`
`git commit -m "Ignore data files and results"`
```console
(base) planets % git add a.dat
The following paths are ignored by one of your .gitignore files:
a.dat
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
(base) planets % git add .
(base) planets % git status
On branch main
nothing to commit, working tree clean
(base) planets % cat .gitignore
*.dat
results/
(base) planets % git status --ignored
On branch main
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
a.dat
b.dat
c.dat
results/
nothing to commit, working tree clean
```
## VC with Git: Remotes
sshSign in to your account on https://github.com/
- Goal: get the `~/Desktop/planets/` repository from part one tracked on GitHub.
On GitHub, make a new repository.
Click green "New" button.
On "Create a new respository" page, set a "Repository name".
Choose public (visible to the world) or private (visible to you and invitees only).
Click "Create repository".
Online, we only have `.git/` and no connection to the work we've done on our local computer.
SSH (secure shell) is recommended.
>[!important] Never share your private key!
```bash=
ls -al ~/.ssh_vlad
ls: cannot access '/c/Users/thompson.4509/.ssh_vlad': No such file or directory
```
```bash=
ssh-keygen -t ed25519 -C "<your-email>"
# Generating the __ keypair.
# Prompt for where to save.
# Press enter
# Prompt to create a passphrase: it will not show output on the bash for security. A passphrase for your ssh keys is optional.
# Confirmation will print:
Your identification has been saved in /c/Users/Vlad Dracula/.ssh/id_ed25519
Your public key has been saved in /c/Users/Vlad Dracula/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:SMSPIStNyA00KPxuYu94KpZgRAYjgt9g4BA4kFy3g1o vlad@tran.sylvan.ia
The key's randomart image is:
+--[ED25519 256]--+
|^B== o. |
|%*=.*.+ |
|+=.E =.+ |
| .=.+.o.. |
|.... . S |ls -al ~/.ssh
|.+ o |
|+ = |
|.o.o |
|oo+. |
+----[SHA256]-----+
```
```bash=
ls -al ~/.ssh
# This will now print something.
```
Copy public key to give to GitHub.
```bash=
cat ~/.ssh/id_ed25519.pub #.pub indicates public key
```
Copy `cat`'s output ^^
Go to GitHub.
Click your profile icon.
Go to Settings
Go to SSH and GPG keys
Click New SSH Key
Name it
Select Authentication key
Paste the public key from your clipboard under "Key"
More detailed documentation by GitHub on SSH configuration can be found [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).
While dealing with SSH configuration, we can use HTTPS for the exercises today. Generally, using SSH is more secure.
PAT
- Profile picture
- Settings
- Developer settings (at the bottom on the left)
- Personal access tokens
- Tokens (classic)
- Generate new token
- Provide the access token when authenticating at the command line
Test:
```bash
ssh -T git@github.com
Hi <user>! You've successfully authenticated, but GitHub does not provide shell access.
```
In GitHub, copy the HTTPS or SSH link to the GitHub repository.
In your shell:
```bash=
git remote add origin <paste-GitHub-repo-link-for-HTTPS-or-SSH>
```
Check the link to GitHub:
```bash=
git remote -v
origin https://github.com/<user>/planets2.git (fetch)
origin https://github.com/<user>/planets2.git (push)
```
Push your local changes to GitHub:
```bash
git push origin main
```
or
```bash
git push -u origin main
```
On GitHub, verify that your computer's `planets/` repo contents are in the GitHub repository.
On GitHub, click 
(your number may be different)
to see the contents of the commits
In shell
```bash=
git checkout <paste-old-commit-hash>
```
If HEAD is detached, use
```bash=
git checkout main
```
On GitHub, use the dropdown branch menu to select `main`.
On bash:
```bash!
git status
```
---
### Collaborating with GitHub
On GitHub, go to Settings.
Click Collaborators
Open one terminal/shell as "Vlad".
Open a second terminal/shell as "Wolfman".
This will simulate a collaboration.
In Vlad's terminal, make a directory for him to work from.
```bash!
mkdir ~/Desktop/vlad-planets
```
In Vlad's shell:
```bash!
git clone git@github.com:<github-username>/planets.git ~/Desktop/vlad-planets
```
In Vlad's shell:
```bash!
cd ~/Desktop/vlad-planets
```
```bash!
nano pluto.txt
```
```nano=
It is SO a planet!
```
Ctrl-O to save, Ctrl-X to exit
```bash=
cat pluto.txt
```
```bash
git status
```
```bash=
git add pluto.txt
```
```bash
git commit -m "Add note about Pluto"
```
```bash
git push origin main
```
Go to GitHub and view the change that was just pushed.
On Vlad's shell
```bash
git status
```
This only see's Vlad's local repository, not the changes to the remote.
```bash
git fetch origin main
```
```bash
git diff main origin/main # What's different between my local main branch and the remote (origin) main branch?
```
This ensures sometheing we don't want will not be pulled.
```bash!
git pull origin main
```
>[!important]Check and pull from the remote BEFORE you make local changes.
On GitHub,
If you click into a commit, you can comment on the diff of the commit or on a line in the code of the commit.
Contextualized communication! 🌈
>[!note]The way GitHub stores the backed up information is efficient in that it stores the changes (diffs) associated with the commits rather than redundant copies of the same files.
### Handling merge conflicts ⚔
In Wolfman's shell
```bash!
cat mars.txt
```
```bash!
nano mars.txt
```
```nano!
# at the bottom ...
This line added to Wolfman's copy.
```
```bash!
cat mars.txt
```
Will show the new line added.
```bash!
git add mars.txt
```
```bash!
git commit -m "Add a line to our home copy"
```
```bash
git push origin main
```
Wolfman has made his changed and shared it to the remote repository.
In Vlad's shell:
```bash
nano mars.txt
```
```nano
# Should only have 3 lines, not the one you just added in Wolfman's terminal
We added a different line in the other copy.
```
```bash=
cat mars.txt
```
```bash=
git add mars.txt
```
```bash=
git commit -m "Add a line in my copy"
```
```bash=
git push origin main
```
```bash=
! [rejected] ...
```

Git needs you to tell it which 4th line is supposed to go there.
```bash=
git pull origin main
```
```bash=
# ...
CONFLICT ...
# ...
```
We have the changes from the remote locally, but it still can't deal with it. We have both copies.
```bash=
cat mars.txt
```
See `<<<<<<< HEAD` in the output. This is what's on our machine.
See `=====`. This is what's on the remote.
Let's decide which to keep.
```bash=
nano mars.txt
```
```nano=
# Delete the <<<<<< HEAD, =====, and >>>> stuff and the conflicting content.
# Add:
We removed a conflicting pair of entries.
```
```bash=
cat mars.txt
```
```bash=
git status
```
```bash=
git add mars.txt
```
```bash!
git commit -m "Merge changes from GitHub"
```
```bash!
git push origin main
```
In other shell:
```bash!
git pull origin main
```
```bash!
git log
```
Observe the "Merge changes from GitHub" commit message made by the other guy.
Work together as a team to minimize merge conflicts. Communicate with your team 🤝
A few additional notes:
- Sharing code on GitHub (or any other remote repository) is helpful in many ways: build and showcase your portfolio, create a community, work with a team ...
Please take a moment to complete the post-workshop survey: https://carpentries.typeform.com/to/UgVdRQ?slug=2024-08-16-online2024-08-16-osu-online