https://github.com/zonca/conversion_tofix
Exercise for Advanced git tutorial
https://github.com/zonca/conversion_tofix
git tutorial
Last synced: 2 months ago
JSON representation
Exercise for Advanced git tutorial
- Host: GitHub
- URL: https://github.com/zonca/conversion_tofix
- Owner: zonca
- License: unlicense
- Created: 2017-08-01T15:27:12.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-08-09T16:30:33.000Z (almost 2 years ago)
- Last Synced: 2025-03-17T23:37:50.396Z (2 months ago)
- Topics: git, tutorial
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 97
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hands-on exercise for Advanced Git/Github training
## Notes
* Feel free to leave anytime
* It is hands-on, try to do exercise, then we will do together
* All the step-by-step solution will be available, no need to take notes
* If you get lost, try to reset the repository and start again
* Otherwise, feel free to just follow along, you can do on your own later## 0) Preparation
* `module load gh` on Expanse
* `gh auth login`, protocol SSH, generate key with no password, authenticate via browser
* Clone this repository to your home folder with `gh repo clone zonca/conversion_tofix`
* `git config --global user.name "FirstName LastName"`
* `git config --global user.email "[email protected]"`## 0b) How to reset the status of the repository
If you ever get lost and have an incosistent status of the repository as you work through the example, you can wipe all local changes both to `main` and to `fix_bug` and go back to the initial state of `main` and restart from there:
git checkout main
git reset --hard origin/original_mainAfter you created the `fix_bug` branch:
git checkout fix_bug
git reset --hard origin/original_main## 1) Make a test
* Test it running `python test_conversion.py`, does it fail?
* Checkout the code version just before the last commit, does it still fail? How do you go back to the last commit?## 2) Identify the commit which caused the bug
* Identify the commit causing the bug with `git bisect`, see
* `bisect` is rarely useful in practice, let's skip it, it is in the solution if you are interested, now assume we know that the problematic commit is `363a`## 3) Fix in branch
* Create a new branch `fix_bug`
* Undo it with `git revert`## 4) Create Pull Request
* Try to push it back to the original repository with `git push origin fix_bug`, does it work?
### Using the Github cli
* Look at `gh` docs at
* Create fork, push the branch to fork and create a PR all from the command line### Using the Github website
* Fork the repository under your Github account through the Github website
* Add your **fork** of the repository as a remote named `fork` to the repository on Expanse
* `git push fork` your `fix_bug` to your repository
* Go to , create a Pull Request!## 5) Synchronize upstream
* I will create a new commit in my repository
* Create 2 branches, test `rebase` in one and `merge` in the other
* After merge, inspect with `git log --graph --oneline`## 6) Synchronize upstream with conflicts
* I will create a new commit in my repository with a conflict
* Do a rebase and handle conflicts## 7) Erase commit
* Use `git rebase` to completely wipe the commit from history
* Try to push## 8) Hard reset
* Wipe the last commit with `git reset --hard`
## 9) Github actions
* Setup a Github action to test the code on the `main` branch of your fork
## 10) Create gist with `gh`
* Publish `conversion.py` as a Gist using `gh`