Compare commits

..

24 commits

Author SHA1 Message Date
Tiziano Zito 02beb4359f add reference to tarot cards meaning 2024-08-29 10:14:45 +03:00
Tiziano Zito a0d4fa9c86 my solution 2024-08-26 16:17:24 +03:00
Tiziano Zito 3bead9f7b6 add full lecture notes 2024-08-26 16:16:49 +03:00
Tiziano Zito 0113bf68b9 Merge pull request 'hide user password on user creation' (#18) from giovannife/2024-heraklion-git:secure-add-user into main
Reviewed-on: #18

Thanks!
2024-08-26 14:47:36 +02:00
ASPP Student f54993e5de hide user password on user creation 2024-08-26 15:44:37 +03:00
Tiziano Zito 4f77cc464f Merge pull request 'implement sha256 hashing of password for security reason' (#7) from romaingu/2024-heraklion-git:hash_pwd into main
Reviewed-on: #7
2024-08-26 14:40:12 +02:00
ASPP Student de4dc255ac implement hashing password where needed 2024-08-26 15:31:17 +03:00
ASPP Student 487f0f9597 fix hashing password 2024-08-26 15:31:04 +03:00
Tiziano Zito 9843b4e994 Merge pull request 'Add a cheatsheet for git commands' (#4) from matthias/2024-heraklion-git:cheatsheet into main
Reviewed-on: #4
2024-08-26 13:55:37 +02:00
ASPP Student 028fb6bf93 implement password hashing function 2024-08-26 14:53:00 +03:00
Matthias Tangemann 92818882f9 add a cheatsheet for git commands 2024-08-26 14:50:17 +03:00
Tiziano Zito b42ef06d91 Merge pull request 'Hide password and capitalize global variables' (#2) from aitor/2024-heraklion-git:safe-psw into main
Reviewed-on: #2
2024-08-26 12:04:22 +02:00
morales-gregorio 54201439cb capitalize global variable 2024-08-26 12:00:16 +02:00
morales-gregorio 975136a539 hidde password typing 2024-08-26 11:40:23 +02:00
Tiziano Zito 4f4fc29312 fix conflicts with Aitor: I win! 2024-08-26 12:27:24 +03:00
Tiziano Zito 65a910ff90 implement name-main trick 2024-08-26 12:08:10 +03:00
morales-gregorio 8a07dbab02 fix stuff 2024-08-26 11:03:02 +02:00
Tiziano Zito 095f4474b0 do not track pwdb with git 2024-08-26 11:37:22 +03:00
Tiziano Zito fa633f7d1a complete implementation of basic API 2024-08-26 11:34:56 +03:00
Tiziano Zito 387430c2f6 lecture notes will follow after the lecture 2024-08-22 11:39:40 +02:00
Tiziano Zito 5ce20dffbf add note about getting files from different branches 2024-08-19 16:15:09 +02:00
Tiziano Zito 10305c4829 add quote by Lars Wirzenius 2024-08-19 15:38:36 +02:00
Tiziano Zito fb8ba56c79 add link to exercise from the README 2024-08-19 13:05:00 +02:00
Tiziano Zito 4e24d45804 link to visualizations 2024-08-19 13:03:50 +02:00
3 changed files with 192 additions and 0 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
pwdb.json pwdb.json
__pycache__

View file

@ -3,6 +3,17 @@
## Setup ## Setup
- Login with your username found on your name badge and set the initial password for your account: https://git.aspp.school/user/login - Login with your username found on your name badge and set the initial password for your account: https://git.aspp.school/user/login
- You'll have to type that password many many times this week: choose wisely! - You'll have to type that password many many times this week: choose wisely!
- We will use the [exercise](exercise.md) in the repo for the rest of the lecture
- find a partner to do pair-programming for this lecture by finding someone with the same tarot card as you
- before starting, make yourself acquainted with the meanining and the power of the tarot cards: carefully read [this booklet](https://aspp.school/wiki/_media/tarot-runic.pdf)
## A cautionary quote
> My first instinct is to sell all my computers, fake my own death, move to another planet, and reinvent computing from scratch, rather than try to understand Git.
>
> I rarely actually do that, mind you. But the urge is there.
— Lars Wirzenius (Linux kernel developer)
## Warm-Up ## Warm-Up
- how to start a repo from scratch? - how to start a repo from scratch?
@ -19,7 +30,11 @@
- how to *move* the whole working directory to a specific point in history? - how to *move* the whole working directory to a specific point in history?
- `git checkout <commit>``DETACHED HEAD` problem, __changes__ __files__ - `git checkout <commit>``DETACHED HEAD` problem, __changes__ __files__
- interaction with branches: `git branch <branch_name>` + `git switch <branch_name>` - interaction with branches: `git branch <branch_name>` + `git switch <branch_name>`
- how to copy a file from a different branch:
- `git checkout <branch> <file>` ➔ the file is staged automatically
- `git restore --source=<branch> <file` ➔ the file is not staged
- `git gui`: building commits along the way interactively (for the *mess around* type of workflows) - `git gui`: building commits along the way interactively (for the *mess around* type of workflows)
- check out these [sketches](git-commands-visualizations.pdf) for a graphical visualization of git commands!
## The Open Source model ## The Open Source model
- remotes: `git pull <from_where> <what>`, `git push <where> <what>`, `git fetch <from_where> <what>`, `git merge <another_branch>` - remotes: `git pull <from_where> <what>`, `git push <where> <what>`, `git fetch <from_where> <what>`, `git merge <another_branch>`

176
cheatsheet.md Normal file
View file

@ -0,0 +1,176 @@
# Git cheatsheet
## Creating a repository
```bash
git init
```
Creates new git repository in current directory.
```bash
git clone <url> (<path>)
```
Clones the repository at the specified url. If no path is specified, the repository will
be cloned into a directory with the same name as the remote repository.
## Branches
```bash
git branch
```
Lists all branches in the repository.
```bash
git branch <branch-name>
```
Creates a new branch with the given name.
```bash
git switch <branch-name>
```
Switches to the specified branch.
```bash
git merge <branch-name>
```
Merges the specified branch into the current branch.
## Making changes
```bash
git status
```
Shows the status of the repository. This includes the current branch and files that have been modified.
```bash
git diff (--staged)
```
Shows the changes that have been made to the files in the repository. Use `--staged` to see changes that have been added to the staging area.
```bash
git add <file>
```
Adds the specified file to the staging area.
```bash
git add .
```
Adds all files in the current directory to the staging area.
```bash
git reset (<file>)
```
Removes the specified file from the staging area. If no file is specified, all files are removed.
```bash
git commit (-m "<message>")
```
Commits all changes in the staging area to the current branch. If the `-m` flag is omitted, a text editor will open to write a commit message.
```bash
git commit --amend
```
Adds the staged changes to the last commit. This can be used for fixing typos in the commit message.
## Undoing changes
```bash
git restore <file>
```
Restores the specified file to the state of the last commit. This undoes uncommitted changes.
```bash
git revert <commit>
```
Creates a new commit that undoes the changes of the specified commit. Use `git log` to find the hash of the commit.
```bash
git reset --hard <commit>
```
Resets the current branch to the specified commit. DANGER: This will remove all changes after the specified commit. Prefer `git revert`.
## Looking at the history
```bash
git log (--oneline)
```
Shows all past commits on the current branch. Use `--oneline` to show a more compact view.
```bash
git show <commit>
```
Shows the changes of the specified commit. Use `git log` to find the has of the commit.
## Remote repositories
```bash
git remote add <remote> <url>
```
Adds a new remote repository with the specified name (e.g. `origin` or `upstream`) and url. Origin is automatically created when cloning a repository.
```bash
git push <remote> <branch>
```
Pushes the specified branch to the remote repository.
```bash
git fetch <remote>
```
Fetches changes from the remote repository.
```bash
git pull <remote> <branch>
```
Fetches changes from the remote repository and merges them into the current branch.
## Typical workflow
```bash
# 1. Fork the repository on GitHub / git.aspp.school
# 2. Clone the repository
git clone <fork-url>
git remote add upstream <upstream-url>
# 3. Create a new branch
git branch <topic-branch>
git switch <topic-branch>
# 4. Make changes to the code
# 5. Add and commit changes
git add .
git commit -m "<message>"
# 6. Push changes to your fork
git push origin <topic-branch>
# 7. Create a pull request on GitHub / git.aspp.school
# 8. Wait for the pull request to be reviewed and merged
# 9. Pull changes from the remote repository
git switch main
git pull upstream main
# 10. Delete the topic branch
git branch -d <topic-branch>
```
Whenever the remote repository is updated (i.e. when a pull request is merged), you need to pull the changes into your local repository.
```bash
git switch main
git pull upstream main
# If you have an active topic branch, you need to rebase it on top of the updated main branch
git switch <topic-branch>
git rebase main
```
## Getting help
```bash
git help <command>
```
Shows the manual page for the specified command (`add`, `commit`, `push`, etc.).
Official Git documentation: https://git-scm.com/docs