❯ git status On branch main Your branch is based on 'origin/main', but the upstream is gone. (use "git branch --unset-upstream" to fixup)
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: lab1/Collatz.java
no changes added to commit (use "git add" and/or "git commit -a")
❯ git add lab1/* The following paths are ignored by one of your .gitignore files: lab1/lab1.iml lab1/out hint: Use -f if you really want to add them. hint: Disable this message with "git config set advice.addIgnoredFile false"
检查是否成功add
1 2 3 4 5 6 7 8
❯ git status On branch main Your branch is based on 'origin/main', but the upstream is gone. (use "git branch --unset-upstream" to fixup)
Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: lab1/Collatz.java
提交修改
1 2 3
❯ git commit -m"done with Collatz" [main 21cb83a] done with Collatz 1 file changed, 5 insertions(+), 7 deletions(-)
When you do this, Git will make a recording of the changes you made to Collatz.java. It will also record the message “done with Collatz” along with the recording. These messages can be helpful if you’re looking to find a specific change at some point in the past.
1 2 3 4 5 6
❯ git status On branch main Your branch is based on 'origin/main', but the upstream is gone. (use "git branch --unset-upstream" to fixup)
What does add do? Add marks a file (or set of files) as something you want to backup.
What does commit do? Commit creates a backup with the given message.
If commit makes a backup but not to GitHub, where did it back up my files? On your own computer!
What good is a backup on your own computer? If you want to go back to an old version, you can do that using git using other commands. By storing the backup locally, restoring old backups is very fast and doesn’t require an internet connection.
What if my computer dies, isn’t the backup made by commit lost? Yes. That’s why there’s a push command.
在IntelliJ里点击Run,然后点View Breakpoints,在Any exception框里打勾,并打勾Condition:,在框里输入 this instanceof java.lang.ArrayIndexOutOfBoundsException
之后再debug,程序就会停在异常即将发生的时候
NOTE: If you use the debug feature without specifying a condition, your code will stop in some various mysterious places. Make sure you never have “Any Exception” checked without having a specified condition. This is because the process of starting JUnit tests generates a bunch of exceptions that ultimately get ignored. This is well beyond the scope of our class. If you’re done using an execution breakpoint, you should uncheck the “Java Exceptions Breakpoints” box in the top left.