Skip to content

Instantly share code, notes, and snippets.

@mngyuan
Last active November 7, 2022 17:59
Show Gist options
  • Save mngyuan/33261558e91a2cef4ef6e957afc1b17d to your computer and use it in GitHub Desktop.
Save mngyuan/33261558e91a2cef4ef6e957afc1b17d to your computer and use it in GitHub Desktop.

Git / GitHub for development basics

Git:

  • distributed version control system
  • originally authored by Linus (of Linux fame)
  • UNIX philosophy of many small chainable tools

Github:

  • online hosting for git repositories
  • CI, issues, merging, forking, releases, remote

Why are Git / Github important for development?

  • Contributing to open source
  • Literacy
  • Bug finding
  • Code health

What is distributed version control?

Diagram showing that distributed version control users all have a copy of the repository, versus centralized where only one copy exists on the server

Pros
  • Redundancy
  • Independent working
  • Local = fast
  • Offline
Cons
  • Stale checkouts
  • Manual merging

Some basic terminology

Github is a remote, which hosts the remote repo. The act of creating your local checkout is called cloning. Commits are changesets. When you and someone else have conflicts, merging creates a commit to resolve those conflicts. When you rebase, you temporary remove your commits, update or fast-forward the branch they're on, and re-apply your commits.

Exercise

Installing Git

Ubuntu

sudo apt install git-all

More info here

Getting Started

git clone git@github.com:cti-one/git-demo.git

High level workflow

  1. Get most recent changes
git pull --rebase

A regular pull:
Diagram showing commits for a regular pull from git
A rebase pull:
Diagram showing commits for a regular pull from git
2. Commit changes

git add <modified-file-name>
git commit -m 'message'
  1. Push changes
git push

What's next?

  • Communication
  • Feature branching (optional)
  • Use the organization, email me for help

Further Reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment