diff --git a/.gitignore b/.gitignore index a2e1756..8f2e53e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ pwdb.json -__pycache__ \ No newline at end of file diff --git a/README.md b/README.md index c68f88f..041767e 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,6 @@ ## Setup - 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! -- 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 - how to start a repo from scratch? @@ -30,11 +19,7 @@ - how to *move* the whole working directory to a specific point in history? - `git checkout ` ➔ `DETACHED HEAD` problem, __changes__ __files__ - interaction with branches: `git branch ` + `git switch ` -- how to copy a file from a different branch: - - `git checkout ` ➔ the file is staged automatically - - `git restore --source= `, `git push `, `git fetch `, `git merge ` diff --git a/cheatsheet.md b/cheatsheet.md deleted file mode 100644 index 813aa43..0000000 --- a/cheatsheet.md +++ /dev/null @@ -1,176 +0,0 @@ -# Git cheatsheet - -## Creating a repository -```bash -git init -``` -Creates new git repository in current directory. - -```bash -git clone () -``` -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 -``` -Creates a new branch with the given name. - -```bash -git switch -``` -Switches to the specified branch. - -```bash -git merge -``` -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 -``` -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 () -``` -Removes the specified file from the staging area. If no file is specified, all files are removed. - -```bash -git commit (-m "") -``` -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 -``` -Restores the specified file to the state of the last commit. This undoes uncommitted changes. - -```bash -git revert -``` -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 -``` -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 -``` -Shows the changes of the specified commit. Use `git log` to find the has of the commit. - - -## Remote repositories -```bash -git remote add -``` -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 -``` -Pushes the specified branch to the remote repository. - -```bash -git fetch -``` -Fetches changes from the remote repository. - -```bash -git pull -``` -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 -git remote add upstream - -# 3. Create a new branch -git branch -git switch - -# 4. Make changes to the code - -# 5. Add and commit changes -git add . -git commit -m "" - -# 6. Push changes to your fork -git push origin - -# 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 -``` - -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 -git rebase main -``` - - -## Getting help -```bash -git help -``` -Shows the manual page for the specified command (`add`, `commit`, `push`, etc.). - -Official Git documentation: https://git-scm.com/docs