一、Git 操作流程图
1.git --help 查看帮助
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git --help
usage: git [--version] [--help] [-C
[--exec-path[=
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help
to read about a specific subcommand or concept.
2.git基础操作
Administrator@PC-xiaobing MINGW64 /d
$ cd D:/Git/ //cd到指定文件
Administrator@PC-xiaobing MINGW64 /d/Git
$ pwd //查看当前文件目录
/d/Git
Administrator@PC-xiaobing MINGW64 /d/Git
$ git init //初始化本地git仓库
Initialized empty Git repository in D:/Git/.git/
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git add test.txt //从工作区添加本地文件test.txt到暂存区
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git commit -m "test" //从暂存区commit提交到本地仓库
//第一次安装Git提交commit的时候提示设置name和邮箱
*** Please tell me who you are.
Run
git config //global user.email "you@example.com"
git config //global user.name "Your Name"
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git config //global user.name "xiaobing" //根据提示设置name
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git config //global user.email "you@example.com" //根据提示设置邮箱
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git commit -m "test" //从暂存区commit提交到本地仓库
[master (root-commit) 9bc4419] test
1 file changed, 1 insertion(+)
create mode 100644 test.txt
//接下来从本地仓库push到远程仓库
3.创建远程仓库GitHub或者GitLib
4.提交变更
git remote add origin https://github.com/xbtest/Demo01.git //git remote 用于管理远程仓库
git push -u origin master //往名字为origin的仓库的master分支上提交变更的代码
Administrator@PC-xiaobing MINGW64 /d/eclipse-workspace/Demo01 (master)
$ git remote add origin https://github.com/xbtest/Demo01.git //添加失败
fatal: remote origin already exists.
$ git remote rm origin //执行rm删除后再次添加
$ git remote add origin https://github.com/xbtest/Demo01.git
第一次提交代码的时候提示登录
报错:
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
▒▒▒▒▒▒▒▒ʱ▒▒▒▒
Username for 'https://github.com': xbtest
Everything up-to-date
Branch master set up to track remote branch master from origin.
这时候需要 更新Windows的git凭证管理器
点击下载安装 GCMW-1.14.0.exe
下载链接
https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0
下载后双击安装即可,再次提交成功:
Administrator@PC-xiaobing MINGW64 /d/Git (master)
$ git push -u origin master
Everything up-to-date
Branch master set up to track remote branch master from origin.
5.验证查看
6.待续….
手机扫一扫
移动阅读更方便
你可能感兴趣的文章