Git and Github.com

Training

UF Research Computing

Matt Gitzendanner

magitz@ufl.edu

What is git?

  • Version Control Software
    • Track changes to files
    • Collaborative
    • Track who made changes
    • Revert changes

https://git-scm.com/

What is github.com?

  • Commercial web site for hosting online git repositories
    • Free options
    • Education plans

Alternatives exist:

and more...

Why use version control?

  • Collaborate
  • History of changes
    • Revert changes
    • See what you did
    • Recover deleted bits
  • Experiment
    • Easy to try something
  • Backup
    • Remote copies

Geting started

Download and install git:

https://git-scm.com/

Github.com

education.github.com

Repositories

e.g.: github.com 

Title Text

git workflow

Create a repo on github.com

My new repo

Create folder, copy/paste

[magitz@login3 ufrc_demo]$ echo "# ufrc_demo" >> README.md
[magitz@login3 ufrc_demo]$ git init
 Initialized empty Git repository in /home/magitz/ufrc_demo/.git/
[magitz@login3 ufrc_demo]$ git add README.md
[magitz@login3 ufrc_demo]$ git commit -m "first commit"
[master (root-commit) ed77e61] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
[magitz@login3 ufrc_demo]$ git branch -M main
[magitz@login3 ufrc_demo]$ git remote add origin git@github.com:magitz/ufrc_demo.git
[magitz@login3 ufrc_demo]$ git push -u origin main
Counting objects: 3, done.
Writing objects: 100% (3/3), 227 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:magitz/ufrc_demo.git
 * [new branch]      main -> main
Branch main set up to track remote branch main from origin.
[magitz@login3 ufrc_demo]$   

Repositories

Branching

  • Diverge from the main line 
    • Keep main files unchanged
  • Test new ideas
  • Fix bugs
  • Develop new features
git branch workshop
git checkout workshop
git checkout -b workshop

or

Merging

  • Bring the changes from a branch back into main branch
  • May need to resolve conflicts
    • Changes made to a file in both branches

Gitflow

  • Branch and merge workflow

GitHub Learning Lab

GitHub Classrooms

GitHub Pages

Host your site at github.com (for free)!

Additional Resources