欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

git HTTP 上传

程序员文章站 2022-06-06 11:18:01
...

1.在Github中创建好仓库后
在git bash中 进行如下操作
aaa@qq.com MINGW64 ~/Desktop
$ cd E:
进入要连接的文件中
aaa@qq.com MINGW64 /e
$ git remote
fatal: not a git repository (or any of the parent directories): .git

aaa@qq.com MINGW64 /e
$ ls
‘$RECYCLE.BIN’/ software/
【十月】长草颜团子:吃土.ssf SogouInput/
1E24BFA93923BD530CA7BF9A4D9FE3F4* SVN/
DeliveryOptimization/ ‘System Volume Information’/
eclipse-jee-mars-2-win86_64/ test/
ibdata1 ‘VMware Workstation’/
java/ ‘WeChat Files’/
log/ WindowsApps/
maven/ WPS/
‘Program Files (x86)’/ WpSystem/
ProgramData/ zhuomian/
qc.log 火狐下载文件/
shopProject/ 文件压缩/
smm.log

aaa@qq.com MINGW64 /e
$ cd test

通过git init 方法将 文件夹生成git 仓库
aaa@qq.com MINGW64 /e/test
$ git init
Initialized empty Git repository in E:/test/.git/

创建名字和邮箱 好让github 识别
aaa@qq.com MINGW64 /e/test (master)
$ git config --global user.email “aaa@qq.com”

aaa@qq.com MINGW64 /e/test (master)
$ git config --global user.name “bLing7788”
通过git status 查看状态
aaa@qq.com MINGW64 /e/test (master)
$ git status
On branch master

No commits yet

Untracked files:
(use “git add …” to include in what will be committed)
tsxt.txt

nothing added to commit but untracked files present (use “git add” to track)
通过 git add 文件名称 将文件添加到缓存区
aaa@qq.com MINGW64 /e/test (master)
$ git add tsxt.txt

aaa@qq.com MINGW64 /e/test (master)
$ git status
On branch master

No commits yet

Changes to be committed:
(use “git rm --cached …” to unstage)
new file: tsxt.txt

提交文件 使用 git commit -m “备注” 将文件提交
aaa@qq.com MINGW64 /e/test (master)
$ git commit -m “first comomit”
[master (root-commit) 4059642] first comomit
1 file changed, 1 insertion(+)
create mode 100644 tsxt.txt
推送 到Github 仓库中 ,一下内容报错 。
aaa@qq.com MINGW64 /e/test (master)
$ git push origin master
fatal: ‘origin’ 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.
正确的方式是,先连接到Github 中的仓库 通过此命令
aaa@qq.com MINGW64 /e/test (master)
$ git remote add origin https://github.com/bLing/project.git
最后再进行推送
aaa@qq.com MINGW64 /e/test (master)
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 220 bytes | 220.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/bLing7788/project.git

  • [new branch] master -> master

aaa@qq.com MINGW64 /e/test (master)
$
git HTTP 上传2.修改文件
直接在 上传的文件修改 修改后进行提交
修改文件后提交第二次
aaa@qq.com MINGW64 /e/test (master)
$ vi tsxt.txt
aaa@qq.com MINGW64 /e/test (master)
$ git add tsxt.txt
warning: LF will be replaced by CRLF in tsxt.txt.
The file will have its original line endings in your working directory

aaa@qq.com MINGW64 /e/test (master)
$ git commit -m “two comomit”
[master da5fbfd] two comomit
1 file changed, 2 insertions(+), 1 deletion(-)

aaa@qq.com MINGW64 /e/test (master)
$ git remote add origin https://github.com/bLing7788/project.git
fatal: remote origin already exists.

aaa@qq.com MINGW64 /e/test (master)
$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 259 bytes | 129.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/bLing7788/project.git
4059642…da5fbfd master -> master
修改后提交第三次**
aaa@qq.com MINGW64 /e/test (master)
$ git add tsxt.txt
warning: LF will be replaced by CRLF in tsxt.txt.
The file will have its original line endings in your working directory

aaa@qq.com MINGW64 /e/test (master)
$ git commit -m “three commit”
[master 94bca38] three commit
1 file changed, 3 insertions(+), 2 deletions(-)

aaa@qq.com MINGW64 /e/test (master)
$ git remote add origin https://github.com/bLing7788/project.git
fatal: remote origin already exists.

aaa@qq.com MINGW64 /e/test (master)
$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes | 11.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/bLing7788/project.git
da5fbfd…94bca38 master -> master
在Github上显示的最后一次提交
git HTTP 上传

3.退回版本
使用Git 查看 log日志
aaa@qq.com MINGW64 /e/test (master)
$ git log
commit 94bca3896b759240aa6a76027b267acc27737286 (HEAD -> master, origin/master)
Author: bLing7788 [email protected]
Date: Mon Jan 13 12:01:34 2020 +0800

three commit

commit da5fbfd17e46a9352b36ae038b1f915d6ca1ff49
Author: bLing7788 [email protected]
Date: Mon Jan 13 11:59:14 2020 +0800

two comomit

commit 405964236c43b0e4b2e3d32e82a24a070ea6c8ee
Author: bLing7788 [email protected]
Date: Mon Jan 13 11:45:20 2020 +0800

first comomit

aaa@qq.com MINGW64 /e/test (master)
$ git --pretty=oneline
unknown option: --pretty=oneline
usage: git [–version] [–help] [-C ] [-c =]
[–exec-path[=]] [–html-path] [–man-path] [–info-path]
[-p | --paginate | -P | --no-pager] [–no-replace-objects] [–bare]
[–git-dir=] [–work-tree=] [–namespace=]
[]
只查看版本号 加上 --pretty=oneline
aaa@qq.com MINGW64 /e/test (master)
$ git log --pretty=oneline
94bca3896b759240aa6a76027b267acc27737286 (HEAD -> master, origin/master) three commit
da5fbfd17e46a9352b36ae038b1f915d6ca1ff49 two comomit
405964236c43b0e4b2e3d32e82a24a070ea6c8ee first comomit
返回指定的版本 使用Git reset --hard 加上版本号前5位
aaa@qq.com MINGW64 /e/test (master)
$ git reset --hard da5fb
HEAD is now at da5fbfd two comomit

aaa@qq.com MINGW64 /e/test (master)
$ git reset --hard da5fbfd
HEAD is now at da5fbfd two comomit

aaa@qq.com MINGW64 /e/test (master)
$ git log --pretty=oneline
da5fbfd17e46a9352b36ae038b1f915d6ca1ff49 (HEAD -> master) two comomit
405964236c43b0e4b2e3d32e82a24a070ea6c8ee first comomit

aaa@qq.com MINGW64 /e/test (master)
$ git reset --hard 94bca9896
fatal: ambiguous argument ‘94bca9896’: unknown revision or path not in the working tree.
Use ‘–’ to separate paths from revisions, like this:
‘git […] – […]’

aaa@qq.com MINGW64 /e/test (master)
$ git log --pretty=oneline
da5fbfd17e46a9352b36ae038b1f915d6ca1ff49 (HEAD -> master) two comomit
405964236c43b0e4b2e3d32e82a24a070ea6c8ee first comomit
返回到head 头部版本中
aaa@qq.com MINGW64 /e/test (master)
$ git reset --hard head
HEAD is now at da5fbfd two comomit

aaa@qq.com MINGW64 /e/test (master)
$ git log --pretty=oneline
da5fbfd17e46a9352b36ae038b1f915d6ca1ff49 (HEAD -> master) two comomit
405964236c43b0e4b2e3d32e82a24a070ea6c8ee first comomit

aaa@qq.com MINGW64 /e/test (master)
$ git reset --hard HEAD
HEAD is now at da5fbfd two comomit
想要后悔回到之前的版本 使用 Git reflog查看
aaa@qq.com MINGW64 /e/test (master)
$ git reflog
da5fbfd (HEAD -> master) aaa@qq.com{0}: reset: moving to HEAD
da5fbfd (HEAD -> master) aaa@qq.com{1}: reset: moving to head
da5fbfd (HEAD -> master) aaa@qq.com{2}: reset: moving to da5fbfd
da5fbfd (HEAD -> master) aaa@qq.com{3}: reset: moving to da5fb
94bca38 (origin/master) aaa@qq.com{4}: commit: three commit
da5fbfd (HEAD -> master) aaa@qq.com{5}: commit: two comomit
4059642 aaa@qq.com{6}: commit (initial): first comomit
git HTTP 上传

相关标签: 安装教程