学习记录(两个问题练习):
问题1:
提前编写好的三个文件:
代码:
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ cd d:
sunyu@LAPTOP-T5VO94NM MINGW64 /d
$ mkdir shixun
sunyu@LAPTOP-T5VO94NM MINGW64 /d
$ cd shixun
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun
$ mkdir html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun
$ cd html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html
$ touch readme.md
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html
$ ls
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html
$ git init
Initialized empty Git repository in D:/shixun/html/.git/
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ touch readme.md
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git branch
**
## 此处将index.html拖入html文件夹!!!
**
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git add .
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git commit -m "添加项目的readme介绍文件!!!"
[master (root-commit) 8157c4f] 添加项目的readme介绍文件!!!
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 readme.md
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git branch
* master
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git branch sy_html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git branch
* master
sy_html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git checkout sy_html
Switched to branch 'sy_html'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git branch
master
* sy_html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ ls
index.html readme.md
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git status
On branch sy_html
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
nothing added to commit but untracked files present (use "git add" to track)
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git add index.html
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git stastus
git: 'stastus' is not a git command. See 'git --help'.
The most similar command is
status
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git commit -m "sy完成了index开发!"
[sy_html 58735ed] sy完成了index开发!
1 file changed, 14 insertions(+)
create mode 100644 index.html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git checkout master
Switched to branch 'master'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git checkout sy_html
Switched to branch 'sy_html'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ touch index.css
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git status
On branch sy_html
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.css
nothing added to commit but untracked files present (use "git add" to track)
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_html)
$ git checkout master
Switched to branch 'master'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ rm index.css
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git status
On branch master
nothing to commit, working tree clean
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git checkout -b sy_css
Switched to a new branch 'sy_css'
**
**## 此处将index.css拖入html文件夹!!!**
**
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_css)
$ git add .
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_css)
$ git commit -m "sy在sy_css完成了index.css开发!"
[sy_css 17f5f17] sy在sy_css完成了index.css开发!
1 file changed, 7 insertions(+)
create mode 100644 index.css
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_css)
$ git checkout master
Switched to branch 'master'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (master)
$ git checkout -b sy_js
Switched to a new branch 'sy_js'
**
## 此处将index.js拖入html文件夹!!!
**
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ git add .
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ git commit -m "sy在sy_js完成了index.js文件!"
On branch sy_js
nothing to commit, working tree clean
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ git add .
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ git commit -m "sy在sy_js完成了index.js文件!"
[sy_js 83fd0cd] sy在sy_js完成了index.js文件!
1 file changed, 5 insertions(+)
create mode 100644 index.js
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ git branch
master
sy_css
sy_html
* sy_js
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ git merge sy_html
Merge made by the 'recursive' strategy.
index.html | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 index.html
sunyu@LAPTOP-T5VO94NM MINGW64 /d/shixun/html (sy_js)
$ gitk
结果:
问题2:
代码:
sunyu@LAPTOP-T5VO94NM MINGW64 ~
$ cd d:
sunyu@LAPTOP-T5VO94NM MINGW64 /d
$ mkdir javademo
sunyu@LAPTOP-T5VO94NM MINGW64 /d
$ cd javademo
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo
$ git init
Initialized empty Git repository in D:/javademo/.git/
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ touch a.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git add .
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git commit -m "提交a.java类!"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'sunyu@LAPTOP-T5VO94NM.(none)')
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git config --global user.name "ssssy"
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git config --global user.email "123456789@qq.com"
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git commit -m "提交a.java类!"
[master (root-commit) 7087920] 提交a.java类!
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ mv a.java b.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git add b.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git rm a.java
rm 'a.java'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: a.java -> b.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git commit -m "修改了文件命名a-b.java"
[master a9b288d] 修改了文件命名a-b.java
1 file changed, 0 insertions(+), 0 deletions(-)
rename a.java => b.java (100%)
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ vim b.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git add .
warning: LF will be replaced by CRLF in b.java.
The file will have its original line endings in your working directory.
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git commit -m "修改了b.java的内容!!!"
[master 8dc745b] 修改了b.java的内容!!!
1 file changed, 1 insertion(+)
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ rm b.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git rm b.java
rm 'b.java'
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ git commit -m "删除了b.java!!!"
git commit -m "删除了b.javagit rm b.java!"
[master 7175fd5] 删除了b.javagit rm b.java!
1 file changed, 1 deletion(-)
delete mode 100644 b.java
sunyu@LAPTOP-T5VO94NM MINGW64 /d/javademo (master)
$ gitk
结果如图所示:
Day01结果!!!