CS61B 學習筆記 Lab 1 javac, java, git


https://sp18.datastructur.es/materials/lab/lab1/lab1

使用Git

https://sp18.datastructur.es/materials/guides/using-git.html

本地倉庫

This is the foundation of git. To summarize, using our photo analogy:

  • git init: Creates a box in which to permanently store panoramic pictures.
  • git add: Takes a temporary photo of one thing that can be assembled into a panoramic photo later.
  • git commit: Assembles all available temporary photos into a panoramic photo. Also destroys all temporary photos.
  • git log: Lists all the panoramic photos we’ve ever taken.
  • git show: Looks at what is in a particular panoramic photo.
  • git checkout: Rearranges files back to how they looked in a given panoramic photo. Does not affect the panormiac photos in your box in any way.
初始化
$ git init
追蹤/未追蹤文件

File Status Lifecyle

查看文件狀態:

$ git status
暫存和提交

暫存:

$ git add FILE

提交:

$ git commit -m MESSAGE

查看操作歷史:

$ git log
撤銷改動

取消暫存:

$ git reset HEAD [file]

修改上次提交:

$ git add [forgotten-file]
$ git commit --amend

將文件恢復到上一次提交狀態:

$ git checkout -- [file]

遠程倉庫

推送:

$ git push origin master

指令:

  • git clone [remote-repo-URL]: Makes a copy of the specified repository, but on your local computer. Also creates a working directory that has files arranged exactly like the most recent snapshot in the download repository. Also records the URL of the remote repository for subsequent network data transfers, and gives it the special remote-repo-name “origin”.
  • git remote add [remote-repo-name] [remote-repo-URL]: Records a new location for network data transfers.
  • git remote -v: Lists all locations for network data transfers.
  • git pull [remote-repo-name] master: Get the most recent copy of the files as seen in remote-repo-name
  • git push [remote-repo-name] master: Pushes the most recent copy of your files to the remote-repo-name.

lab1

了解以上Git使用部分后再進行lab1操作。

  1. 在github上創建一個倉庫,如cs61b-sp18-logs,並克隆到本地:
$ git clone https://github.com/ikventure/cs61b-sp18-logs.git
  1. 切換文件夾,拉取skeleton中的作業初始代碼
$ cd cs61b-sp18-logs

$ git remote add skeleton https://github.com/Berkeley-CS61B/skeleton-sp18.git

$ git pull skeleton master

  1. HelloWorld.javaHelloNumbers.java放入lab1並推送到個人倉庫中
$ git add lab1/*
$ git commit -m "completed first part of lab1"

$ git push [-u] origin master

  1. 完成LeapYear.java並提交到個人倉庫

  2. 通過github提交到評分系統gradescope(不過課程里面正好只有lab1是關閉的)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM