Open DaidalosCheung opened 6 years ago
sudo ipsec up [vpn-name]
Return
$ cd /home/user/my_project (Go to target respiratory)
For empty folder: $ git init 我们只是做了一个初始化,项目文件尚没有被跟踪_
For non-empty folder: *$ git add 「.c」 $ git add LICENSE $ git commit -m 'initial project version'**
Clone respiratory already existed:
$ git clone https://github.com/libgit2/libgit2 将在当前路径里创建一个 “libgit2” 的文件夹,并将远程仓库内容复制进去
$ git clone https://github.com/libgit2/libgit2 mylibgit 与上一致,远程仓库的文件将会复制进 “mylibgit” 文件夹
$ git status 检视当前所有文件夹的 git 状态,状态分为 tracked 和 untracked:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
clean 表示所有的更改都已经保存
$ git add "add precisely this content to the next commit”, can be applied in multipurpose:
$ git diff To see what you’ve changed but not yet staged
$ git add . add all new update into staged
$ git commit -m "我增加了一个修改"
[master 3d7bdf2] 我增加了一个修改
1 file changed, 2 insertions(+)
Which branch you committed to [master], what SHA-1 checksum the commit has [3d7bdf2]
$ git commit --amend 撤销上一次递交,注意此操作不可恢复
$ git rm
$ git log -p -2 显示最近2次更改记录,并以补丁(--patch)显示修改的内容 $ git log --stat $ git log --pretty=oneline 一行内显示简要内容 $ git log --pretty=format:"%h %s" --graph 显示简要哈希值(%h),显示提交说明(%s), 并且以图例方式显示分支与合并 详情请见 Git 的 53 页
commit 3d7bdf2ca274bec78dc401ff98de8ab5b6cc7dc7 (HEAD -> master)
Author: Ray Cheung [daidalos@link.cuhk.edu.hk]
Date: Mon Oct 26 23:33:14 2020 -0400
This is the 2nd test commit
commit 68af1c36d25d35d7ce56cc504ccc0ea91e1e3dbc
Author: Ray Cheung [daidalos@link.cuhk.edu.hk]
Date: Mon Oct 26 23:32:00 2020 -0400
This is the 1st commit
One of the more helpful options is -p or --patch, which shows the difference (the patch output) introduced in each commit. You can also limit the number of log entries displayed, such as using -2 to show only the last two entries.
$ git checkout [Hash] 回滚到某一个版本。
无论是 git checkout 还是 git diff 都可以使用 hash value 来追踪和比对
$ git remote add [shortname][url] 从[url]添加一个新的远程 Git 仓库,同时指定一个方便使用的简写 [shortname] $ git remote show [remote] 查看当前的 [remote] 的相关信息
ray@ray-ThinkPad-T440p:~/Desktop/Coding/Python$ git remote show try_git
* remote try_git
Fetch URL: https://github.com/DaidalosCheung/Python.git
Push URL: https://github.com/DaidalosCheung/Python.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
查找什么文件已经被 staged 了
- Git
- Github