Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master) $ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
新增文件之后再次查看状态,检测到未追踪的文件
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ vim hello.txt
hello git!
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello.txt
nothing added to commit but untracked files present (use "git add" to track)
2.4 添加暂存区
将工作区的文件添加到暂存区
git add 文件名
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git add hello.txt warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory.
查看状态(检测到暂存区有新文件)
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: hello.txt
2.4 提交本地库
git commit -m “日志信息” 文件名
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git commit -m "my first commit" hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory.
[master (root-commit) 86366fa] my first commit
1 file changed, 16 insertions(+) create mode 100644 hello.txt
查看状态(没有文件需要提交)
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status On branch master
nothing to commit, working tree clean
2.6 推送本地分支到远程仓库
语法
git push 别名 分支
案例实操
git push -u origin master
push如果出现以下错误,尝试下方两个方法:
! [rejected] master -> master (fetch first) error: failed to push some refs to ‘https://github.com/shadowlim/course_design.git’