git 介绍
- GitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格式进行托管,故名GitHub。
- GitHub于2008年4月10日正式上线,除了Git代码仓库托管及基本的 Web管理界面以外,还提供了订阅、讨论组、文本渲染、在线文件编辑器、协作图谱(报表)、代码片段分享(Gist)等功能。目前,其注册用户已经超过350万,托管版本数量也是非常之多,其中不乏知名开源项目 Ruby on Rails、jQuery、python 等。
- 2018年6月4日,微软宣布,通过75亿美元的股票交易收购代码托管平台GitHub。
- 2019年05月,《个人电脑杂志》网站报道,GitHub正遭到一名黑客的入侵。据称,这名黑客先擦除代码资源库,然后向用户索要赎金,作为恢复数据的交换。
git 功能
- 分布式版本控制;
- 多个开发人员协调工作;
- 有效监听谁做的修改;
- 本地以及远程操作;
git 日常命令
git Basic Order
git init // 初始化本地仓库
git add // 添加文件
git status // 查看状态
git commit // 提交
git push // 推送到仓库
git pull // 从远程仓库拉取数据
git clone // 从远程仓库拷贝数据
git install
git start
- 在本地新建一个文件夹myapp,在命令行模式下cd到myapp文件夹下
- 在命令行中用touch命令创建index.html文件
- 第一次使用需配置用户名邮箱
git config
global 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)
$
来源:oschina
链接:https://my.oschina.net/bigShrimp2020/blog/3159959