Workshop on the basics of git
Will be held on 29th of January in 5416.0057 from 13:00 to 17:00
https://myuniversity.rug.nl/infonet/medewerkers/intracom/calendar/workshop-introduction-git
This repository has been archived on 2023-11-08. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Bastian d3eff630ad added ToC 2020-01-09 13:50:49 +01:00
README.md added ToC 2020-01-09 13:50:49 +01:00
factorial.py initial commit 2020-01-08 12:45:39 +00:00
fibonacci.py initial commit 2020-01-08 12:45:39 +00:00

README.md

Table of Contents

How to Git started

Using a GUI

You can use any GUI for git, the ones we use are Fork and Sourcetree
You can download these at https://www.sourcetreeapp.com/ and https://git-fork.com/

For other GUIs check out https://git-scm.com/downloads/guis/

Our remote git server is located at https://git.web.rug.nl/
You can log in with your usual p-number and password.

Learning objectives

  • Introduction to VCS
  • Create new repository
  • Git ignore file
  • Staging
  • Committing
  • Git push
  • Git pull request
  • Branching
  • Merge / Rebase
  • Amend commits
  • Revert and reset
  • Tag
  • Log

Assignments

Assignment 1: Create a repository

  1. Create your own new repository
  2. Add a .gitignore file
  3. Why you would like a gitignore file
  4. Not pushing sensitive files
  5. Not pushing environment files
  6. Add a README

Assignment 2: Your first commit

  1. Clone repository
  2. Edit README file
  3. Create a new file(s) and add information
  4. Stage README and your file(s)
  5. Commit README and your file(s)

Assignment 3: Merge conflicts

  1. Go to the How to Git started repository
  2. Add factorial.py and fibonacci.py to your repository
  3. Choose a partner
  4. Add him/her as a collaborator
  5. Make the partner clone your repository
  6. Let both of you edit the same line in the code file
  7. Let one of you stage and push the changes
  8. Solve the merge conflict

Assignment 5: Branching

  1. Go to the How to Git started repository
  2. Add index.html to your shared repository.
  3. Let person A create a new branch called header
  4. Let person B create a new branch called footer
  5. Let person A edit the header of index.html
  6. Let person B edit the footer of index.html
  7. Stage and push the changes
  8. Pull the latest changes
  9. Track the branch of your partner

Assignment 6: Merge branches (Or Rebase)

  1. Go to your master branch
  2. Merge it with the header branch
  3. Commit the merge
  4. Merge it with the footer branch
  5. Commit the merge
  6. Push the changes
  7. Delete your old branches

Assignment 7: Pull requests

  1. Let one of you create a new repository (do not add collaborators)
  2. Stage and commit a file
  3. Let the other person fork the repository and clone it
  4. Let him/her change the file and push it
  5. Let him/her create a new pull request via the GUI
  6. Let the other approve and merge the request
  7. Let the other pull the latest changes

Assignment 8: Undo / Revert commit

Assignment 9:

Check the logs

Using the terminal

Getting started

Set up your git info

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

If you want to save your https credentials run

git config --global credential.helper store
Omit --global to set the identity only in this repository.

Or you can add an SSH key

Saving changes

See changes that have been made

git diff

Adding files to commit

git add file1 file2
git add *

Committing files with commit message

git commit -m "your commit message"

unstage by using

use "git reset HEAD <file>..." to unstage

Creating a new branch

git branch <branchname>
git checkout -b <branchname>

Going to different branch

git checkout <branchname>

Seeing available branches

git branch -a

Track remote branch

git checkout --track origin/<branch>

Delete remote branch

git push <remote_name> --delete <branch_name>
git remote prune <remote_name>

Check the log in graph form

git log --graph --oneline