Git介绍和日常命令
git start
- 在本地新建一个文件夹myapp,在命令行模式下cd到myapp文件夹下
- 在命令行中用touch命令创建index.html文件
- 第一次使用需配置用户名邮箱
git configglobal user.name "ChangJun
git config --global user.email "779199489@qq.com
git add index.html // 添加一个文件`
git status // 在这个过程中随时可以使用这个命令查看状态
git init // 增加git目录
git rm --cached index.html // 删除添加的文件
git add . // 上传所有文件
git commit -m "" // 上传并备注
git operation
touch .gitignore // 创建git忽略文件,在其中写入要忽略的文件。git branch login // 创建分支
git checkout login // 切换分支
touch login.html
git add . // 上传到当前分支
git remote add origin // 远程仓库地址
git remote // 检查连接
git push -u origin master // 上传
git file upload example
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
Error.java
MyFile.java
Position.java
ProcessByteStream.java
SelectByteStream.java
Token.java
nothing added to commit but untracked files present (use "git add" to track)
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git add *
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git push
error: src refspec refs/heads/master does not match any
error: failed to push some refs to "https://github.com/Jianzhong2076/study.git"
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git commit "add code"
error: pathspec "add code" did not match any file(s) known to git
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git push
error: src refspec refs/heads/master does not match any
error: failed to push some refs to "https://github.com/Jianzhong2076/study.git"
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: Error.java
new file: MyFile.java
new file: Position.java
new file: ProcessByteStream.java
new file: SelectByteStream.java
new file: Token.java
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git commit "add"
error: pathspec "add" did not match any file(s) known to git
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git add *
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git commit "all"
error: pathspec "all" did not match any file(s) known to git
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ ^C
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git pull
Your configuration specifies to merge with the ref "refs/heads/master"
from the remote, but no such ref was fetched.
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git branch
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git commit "aa"
error: pathspec "aa" did not match any file(s) known to git
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git commit -m "aa"
*** 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 "bj_gj@LAPTOP-HP75CG0K.(none)")
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ ^C
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git config --global user.email "bj_gjz@qq.com"
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git config --global user.name "jianzhong2076"
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git commit -m "aa"
[master (root-commit) 48e3447] aa
6 files changed, 460 insertions(+)
create mode 100644 Error.java
create mode 100644 MyFile.java
create mode 100644 Position.java
create mode 100644 ProcessByteStream.java
create mode 100644 SelectByteStream.java
create mode 100644 Token.java
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git push
fatal: unable to access "https://github.com/Jianzhong2076/study.git/": Failed to connect to github.com port 443: Timed out
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git push
fatal: unable to access "https://github.com/Jianzhong2076/study.git/": Failed to connect to github.com port 443: Timed out
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git config --global http.proxy http://127.0.0.1:1080
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git config --global https.proxy http://127.0.0.1:1080
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git push
fatal: unable to access "https://github.com/Jianzhong2076/study.git/": Failed to connect to 127.0.0.1 port 1080: Connection refused
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git status
On branch master
Your branch is based on "origin/master", but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
nothing to commit, working tree clean
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git pull
fatal: unable to access "https://github.com/Jianzhong2076/study.git/": Failed to connect to 127.0.0.1 port 1080: Connection refused
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git pull
fatal: unable to access "https://github.com/Jianzhong2076/study.git/": Failed to connect to 127.0.0.1 port 1080: Connection refused
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ ^C
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git config --global --unset http.proxy
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git pull
Your configuration specifies to merge with the ref "refs/heads/master"
from the remote, but no such ref was fetched.
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git pull
fatal: "origin master" does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git pull
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$ git push
fatal: TaskCanceledException encountered.
▒▒ȡ▒▒һ▒▒▒▒▒▒
jianzhongGjzEnumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 5.26 KiB | 2.63 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0)
To https://github.com/Jianzhong2076/study.git
* [new branch] master -> master
bj_gj@LAPTOP-HP75CG0K MINGW64 /d/code/study (master)
$
以上是 Git介绍和日常命令 的全部内容, 来源链接: utcz.com/z/512881.html