Git, GitHub, & Markdown Resources

Contents

Git, Github, and Markdown

GitHub OctoCat

Git

GitHub

octocat logo

Markdown

Vocabulary

Repo or repository (n.)
A discrete project on GitHub that contains a set of files, a change history, and a set of contributors. (E.g. this one)
Fork (v.)
To copy a repo’s files and version history to a new one with its own settings (preserves connection with original repo but doesn’t interfere).
Clone (v.)
To download a local copy of a repo on GitHub with a tracked connection to the remote repo.
Local (adj.)
On your computer.
Remote (adj.)
On someone else’s computer (aka ‘the cloud’).
Branch (n.)
A version of a repository with its own history. Branches can be created for a unique set of changes and later merged with the main branch to avoid file conflicts.
Commit
(v.) To package and label a discrete set of changes to a repository.
(n.) A set of changes that has been committed.

2. Writing in Markdown

# First level heading 

## Second-level heading

Paragraph with **bold** text and *italicized* text. 

[This is linked text](www.myurl.com)

![This is an image with alt text](imageurl.jpg)

See this cheat sheet for more markdown syntax.

Your Turn

  1. In Visual Studio Code, create a new file (File > New File) named myfile.md
  2. Open the file and write some content using markdown syntax: include headers, images, and links
  3. Save your file
  4. On the left sidebar, right-click on the filename and select Open Preview to see what your site looks like in rendered markdown

3. Using GitHub

We’ll take a tour of a repository for an open-source word cloud generator

amueller/word_cloud

word cloud of US constitution

How to create a repository

Your turn

Create a repo from a template

Editing and uploading content

- Use the pencil icon to edit the README.md file - Add some text and save your work using the **Commit changes** button - Change the **commit message** so that it describes your changes - Select 'commit directly to the main branch' and click **Commit changes**
- Now let's upload the markdown file you created earlier. - Back in your browser, select **Add file > Upload files**. - Drag and drop `myfile.md` into your repository - Add a message when you **commit** your changes

4. Branching & Collaboration with Git

Branching workflow

Branches make collaboration easier by avoiding file conflicts ![github branching diagram](https://docs.github.com/assets/cb-42360/images/help/repository/branching.png)
1. Commit changes to a new **branch** that diverges from the main tree 2. Open a pull request to propose your changes 3. A team member reviews the pull request and discusses any conflicts 4. Merge pull request: incorporate your changes into the main branch
## Your turn > 1. Make another edit to your README.md file and **Commit** it > 3. **Commit** your change and add a commit message > 5. This time select 'create a new branch & open a pull request' > 6. Review & **merge** the pull request > 7. Look at your repository's commit history

5. Working locally

Git enables you to have a local version of your repository (on your computer) that is connected to the remote (on ‘the cloud’) version.

By pulling commits from remote to local and pushing commits from local to remote, you can control the version history of both.

Installing Git

GitHub Desktop

Install a GUI client (an application with a graphical user interface) such as GitHub desktop

Command line

Install Git here to use it from the command line and/or use Git/GitHub features for VS Code or another text editor </section>

Configuration

GitHub Desktop

Visual Studio Code

Command line

Open a terminal window and type:

git config --global user.name "Firstname Lastname"

When you push, you will have to authenticate to github with a personal access token

Clone the repository

Visual Studio Code

GitHub Desktop

Command line

6. Git Versioning process

Git workflow

Add or Stage changes

git add newfile.md

After you create a new file or save changes, staging tells Git to track the file.

commit

git commit -m "message describing my changes"

Package your staged changes and label them for others’ awareness

pull

git pull

Update your local repo with any changes that have been committed to the remote repo

push

git push origin main

Send your changes to the remote repository and publish them on GitHub

Other commands

Your turn

xkcd comic on Git

Remember, it’s ok to mess up! Source: xkcd

Resources

Git

GitHub

Content by Alice McGrath and licensed cc-by-nc-sa