icecream.py | ||
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.
This README has been written in markdown.
To get started see the following cheat sheet:
Cheatsheets:
Markdown
Learning objectives
- Introduction to VCS
- Create new repository
- README.md
- Git ignore file
- Staging
- Committing
- Git push
- Git pull request
- Branching
- Merge / Rebase
- Undoing Things
- Amend commits
- Unstaging
- Unmodifying a modified file
- Revert and reset
- Tag
- Log
Assignments
Assignment 1: Create a repository
- Create your own new repository
- Add a .gitignore file
- Why you would like a gitignore file
- Not pushing sensitive files
- Not pushing environment files
- Add a README.md
Assignment 2: Your first commit
- Clone repository
- Edit README file
- Create a new file(s) and add information
- Stage README and your file(s)
- Commit README and your file(s)
Assignment 3: Merge conflicts
- Go to the How to Git started repository
- Add icecream.py to your repository
- Choose a partner
- Add him/her as a collaborator
- Make the partner clone your repository
- Let both of you edit the same line in the code file
- Let one of you stage and push the changes
- Solve the merge conflict
Assignment 5: Branching
- Go to the How to Git started repository
- Add index.html to your shared repository.
- Let person A create a new branch called header
- Let person B create a new branch called footer
- Let person A edit the header of index.html
- Let person B edit the footer of index.html
- Stage and push the changes
- Pull the latest changes
- Track the branch of your partner
Assignment 6: Merge branches (Or Rebase)
- Go to your master branch
- Merge it with the header branch
- Commit the merge
- Merge it with the footer branch
- Commit the merge
- Push the changes
- Delete your old branches
Assignment 7: Pull requests
- Let one of you create a new repository (do not add collaborators)
- Stage and commit a file
- Let the other person fork the repository and clone it
- Let him/her change the file and push it
- Let him/her create a new pull request via the GUI
- Let the other approve and merge the request
- Let the other pull the latest changes
Assignment 8: Undo / Revert commit
Assignment 9:
Check the logs
Using the terminal
Configure tooling
Configure user information for all local repositories
$ git config --global user.name "[name]"
Sets the name you want attached to your commit transactions
$ git config --global user.email "[email address]"
Sets the email you want attached to your commit transactions
$ git config --global color.ui auto
Enables helpful colorization of command line output
If you want to save your https credentials run
```shell
git config --global credential.helper store
Omit --global to set the identity only in this repository.
Or you can add an SSH key
Terminal commands
See changes that have been made
git diff
Adding files to commit
git add file1 file2
git add *
Committing files with commit message, this will stage your changes
git commit -m "your commit message"
unstage by using
use "git reset HEAD <file>..." to unstage
Branches
Branches are an important part of working with Git. Any commits you make will be made on the branch you’re currently “checked out” to. Use git status to see which branch that is.
Creates a new branch
$ git branch [branch-name] git checkout -b <branchname>
Switches to the specified branch and updates the working directory
$ git checkout [branch-name]
Combines the specified branch’s history into the current branch. This is usually done in pull requests, but is an important Git operation.
$ git merge [branch]
Deletes the specified branch
$ git branch -d [branch-name]
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