updated tutorial

This commit is contained in:
LiviaMedeiros 2021-12-05 17:59:29 +08:00
parent 524fe24600
commit 04c85075d4
Signed by: LiviaMedeiros
GPG Key ID: 6E5412F8214FF24A
1 changed files with 40 additions and 34 deletions

View File

@ -30,7 +30,7 @@ You need to do this phase only once.
0. **Register, fork**<br>
The main aka upstream repo is here: https://git.rayshift.io/kamihama/magia-assets.git
1. **Clone the forked repo**<br>
1. **Clone the forked repo**
```bash
$ git clone ssh://git@git-ssh.rayshift.io:45555/LiviaMedeiros/magia-assets.git
Cloning into 'magia-assets'...
@ -45,13 +45,13 @@ Updating files: 100% (55730/55730), done.
Takes a while, consumes space, consumes traffic.<br>
Also consumes traffic and some resources on the server so try to never repeat this step (i.e. make backup locally and restore it if something goes terribly wrong instead of cloning again).
2. **Go into directory**<br>
2. **Go into directory**
```bash
$ cd magia-assets
```
All of future steps are assuming that you are here, or that you're using `-C /path/to/your/magia-assets` and know what's goingon.
3. *Check if everything is fine*<br>
3. *Check if everything is fine*
```bash
$ git status
On branch master
@ -60,13 +60,13 @@ Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
```
4. **Add remote upstream**<br>
4. **Add remote upstream**
```bash
$ git remote add upstream ssh://git@git-ssh.rayshift.io:45555/kamihama/magia-assets.git
```
You'll need that to keep the fork in sync with upstream.
5. *Check if remotes are fine*<br>
5. *Check if remotes are fine*
```bash
$ git remote -v
origin ssh://git@git-ssh.rayshift.io:45555/LiviaMedeiros/magia-assets.git (fetch)
@ -85,7 +85,7 @@ You can do this part at any time after each upstream update just to keep it sync
This part assumes that if you had some previous contributions, they are already merged into upstream/master.<br>
And that no one else is touching the same files as you plan to.
1. *Check if everything is fine*<br>
1. *Check if everything is fine*
```bash
$ git status
On branch master
@ -98,7 +98,7 @@ $ git branch
* master
```
2. **Fetch upstream data**<br>
2. **Fetch upstream data**
```bash
$ git fetch upstream
remote: Enumerating objects: 415, done.
@ -109,16 +109,16 @@ Receiving objects: 100% (217/217), 10.24 MiB | 6.46 MiB/s, done.
Resolving deltas: 100% (160/160), completed with 121 local objects.
From ssh://git-ssh.rayshift.io:45555/kamihama/magia-assets
* [new branch] master -> upstream/master
```
3. **Switch to `master` branch**<br>
```bash
$ git checkout master
```
3. **Switch to `master` branch**
```bash
$ git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.
```
4. **Merge upstream master into fork master**<br>
4. **Merge upstream master into fork master**
```bash
$ git merge upstream/master
Updating 1f93676b..eb8631e7
@ -131,7 +131,7 @@ Fast-forward
330 files changed, 60186 insertions(+), 31794 deletions(-)
```
5. *Check if everything is fine*<br>
5. *Check if everything is fine*
```bash
$ git status
On branch master
@ -141,7 +141,7 @@ Your branch is ahead of 'origin/master' by 1 commit.
nothing to commit, working tree clean
```
6. *Push synced master branch on remote*<br>
6. *Push synced master branch on remote*
```bash
$ git push
Enumerating objects: 415, done.
@ -163,7 +163,7 @@ To ssh://git-ssh.rayshift.io:45555/LiviaMedeiros/magia-assets.git
Not a necessary step but highly recommended: otherwise your fork will look confusing in the web interface.<br>
Ignore the link and suggestion to create PR here, it's not needed.
7. *Check if everything is fine*<br>
7. *Check if everything is fine*
```bash
$ git status
On branch master
@ -176,13 +176,16 @@ nothing to commit, working tree clean
## Branching
This is where you start your own work.
1. **Make a new branch from `master`.**<br>
1. **Make a new branch from `master`.**
```bash
$ git checkout -b tutorial-adjustments master
Switched to a new branch 'tutorial-adjustments'
```
2. *Check if everything is fine*<br>
Branch name doesn't have to be very meaningful, but it would be a good idea to make them distinct.<br>
The most simple way to achieve that is to include creation date, e.g. `adjustments-211205`.
2. *Check if everything is fine*
```bash
$ git branch
master
@ -198,7 +201,7 @@ nothing to commit, working tree clean
## Doing things
This particular part is repeatable. Do the things until you're satisfied with results. If everything went really wrong, ~~delete the new branch and~~ start the work phase again.
1. *Check if everything is fine*<br>
1. *Check if everything is fine*
```bash
$ git status
On branch tutorial-adjustments
@ -210,7 +213,7 @@ At this point, checking is actually important, especially if you already committ
This part is up to you.<br>
In this tutorial, we'll mess up with scenarios. Let's go into `magica/resource/download/asset/master/resource/scenario/json/adv/` and mess with M-Girl stories.
3. **Look at what you've done**<br>
3. **Look at what you've done**
```bash
$ git status
On branch tutorial-adjustments
@ -245,7 +248,7 @@ Here we did 4 things:
Looks good.
4. **Add the files**<br>
4. **Add the files**
```bash
$ git add .
```
@ -271,11 +274,10 @@ Changes to be committed:
deleted: magica/resource/download/asset/master/resource/scenario/json/adv/scenario_3/340033-6.json
new file: magica/resource/download/asset/master/resource/scenario/json/adv/scenario_3/380221-1.json
new file: magica/resource/download/asset/master/resource/scenario/json/adv/scenario_3/380221-2.json
```
Still looks good.
6. **Commit changes**<br>
6. **Commit changes**
```bash
$ git commit -m "tutorial commit"
[tutorial-adjustments 46e70151] tutorial commit
@ -288,14 +290,14 @@ $ git commit -m "tutorial commit"
delete mode 100644 magica/resource/download/asset/master/resource/scenario/json/adv/scenario_3/340033-6.json
create mode 100644 magica/resource/download/asset/master/resource/scenario/json/adv/scenario_3/380221-1.json
create mode 100644 magica/resource/download/asset/master/resource/scenario/json/adv/scenario_3/380221-2.json
```
Of course you can omit the `-m "tutorial commit"` part and write commit message in a different format; or add more stuff like `-S`; etc.<br>
Or maybe you repeated this step to include some missing changes to your previous commit and used `--amend` here? It's okay as well.<br>
~~Or maybe...~~ Nvm, everything looks great.
7. *Check if everything is fine*<br>
```bash
$ git status
```
Of course you can omit the `-m "tutorial commit"` part and write commit message in a different format; or add more stuff like `-S`; etc.<br>
Or maybe you repeated this step to include some missing changes to your previous commit and used `--amend` here? It's okay as well.<br>
~~Or maybe...~~ Nvm, everything looks great.
7. *Check if everything is fine*
```bash
$ git status
On branch tutorial-adjustments
nothing to commit, working tree clean
```
@ -316,7 +318,7 @@ On branch tutorial-adjustments
nothing to commit, working tree clean
```
2. *Check if the history looks as intended*<br>
2. *Check if the history looks as intended*
```bash
$ git log --oneline
caf36505 (HEAD -> tutorial-adjustments) SNAA
@ -326,14 +328,14 @@ eb8631e7 (upstream/master, origin/master, origin/HEAD, master) 20210530-1 (#16)
```
Nothing weird here: it's the latest new commit ([caf36505](https://git.rayshift.io/LiviaMedeiros/magia-assets/commit/caf365057396c0f336b8b61e670a789f04c5da40)), then the rest of new commits ([46e70151](https://git.rayshift.io/LiviaMedeiros/magia-assets/commit/46e70151a028aa747590ab73fd23119b324e8005)), then the latest upstream/master commit ([eb8631e7](https://git.rayshift.io/LiviaMedeiros/magia-assets/commit/eb8631e74681f0318d547235620c1ef61eff7411)), then everything else ([1f93676b](https://git.rayshift.io/LiviaMedeiros/magia-assets/commit/1f93676bba1ea23ca8bc21f2849300be9a482896) and so on). No unnecessary merge commits, no undoing commits, all clean.
3. *Check if the changes look as intended*<br>
3. *Check if the changes look as intended*
```bash
$ git diff master..tutorial-adjustments
[a lot of stuff]
```
Third check in a row: still not mandatory, but it's still a point of no return.
4. **Push the branch**<br>
4. **Push the branch**
```bash
$ git push --set-upstream origin tutorial-adjustments
Enumerating objects: 40, done.
@ -359,6 +361,10 @@ Check everything again, make a new Pull Request, describe&comment it if needed.
The work phase ends here. To keep everything simple, just wait until the PR is accepted and merged into upstream/master, and then you can ~~delete the merged branch and~~ start the work phase again.
Note: usually, when your PR is merged "as is", it is totes safe to delete the merged branch, since it becomes a subset of upstream/master.<br>
However, if it's accepted via "squash and merge" method, I'd recommend to keep it as the most explicit and reliable way to access the individual commit history.<br>
One way to check the merge method is to go to [upstream/master commit history](https://git.rayshift.io/kamihama/magia-assets/commits/branch/master). If you see the exact same commits from your branch and maybe "Merge pull request" afterwards, it was a regular merge. If you see just one brand new commit which contains your whole PR, it was squash&merge.
# Tl;dr
Init phase (only once):