Introduction to Git and GitHub

https://ubc-library-rc.github.io/intro-git/

Land Acknowledgement

UBC Vancouver is located on the traditional, ancestral, and unceded territory of the xʷməθkʷəy̓əm (Musqueam) peoples.

Use the Zoom toolbar to engage The Zoom toolbar

Participants window

The participants menu
annotate menu
annotation toolbar

I have never used the command line

I use the command line often


Learning Objectives

  • Create a Git repository on their local machine and track changes
  • Create a remote repository on Github
  • Link a local Git repository to a remote Github repository and sync changes
  • List Git and Github features for project development and team collaboration

Pre-workshop setup

  • Install Bash Shell and Git
  • Create a free Github account

For more information, check out Pre-workshop setup

What is version control?

Benefits of version control

  • collaboration
  • versioning
  • rolling back
  • understanding context
  • backup

Git: open source tool installed on your local computer to track changes made to a set of files (referred to as a git repository)

GitHub: a popular website for hosting and sharing Git repositories

Some Linux commands


						$ cd [directory-name]
					

						$ mkdir [new-directory-name]
					

						$ ls
					

						$ touch [file-name]
					

Git Workflows

  • Making and maintaining a repository on your machine
  • Creating a repository on Github
  • Syncing local repository with Github
  • Forking projects and working collaboratively

Creating a repository


						$ mkdir hello-world
						$ cd hello-world

						$ git init
					

Displaying project status


						$ git status
					
  • branch main
  • commit

Git Workflow on your local machine

Git commands

Diff and log command


						$ git diff
						$ git diff HEAD
						$ git log
					

Git branches


						$ git branch
						$ git branch new-feature
						$ git checkout new-feature
					

Other features

  • .gitignore
  • Why staging is useful
  • Undoing changes in Git
  • Git tags

Github repositories

https://github.com/

Linking your local repository to Github

Git remote


						$ git remote add origin https://github.com/[your_github_username]/[github-repository-name].git
						$ git remote -v
					

HTTPS connection to remote

Configure access token on Github


						$ git remote set-url origin https://[github-token]@github.com/
						[your_github_username]/[github-repository-name].git
					

Git push and pull


						$ git push -u origin main
						$ git pull
					

Collaboration on GitHub

Collaboration on GitHub

Git and open source community

Hacktoberfest is a month-long celebration of open-source software by DigitalOcean that encourages participation in giving back to the open-source community.

Github features

A sandbox repository

Link to the repository

Git and Visual Studio Code

Try it out!

Instructons in Git basics section of site
https://ubc-library-rc.github.io/intro-git/