目录
创建分支git checkout –b branchname
查看用户名和邮箱git config user.name/user.email
在使用http克隆等操作时,如未在添加凭证,需要添加,凭证的用户名和密码查看路径为,setting-HTTP Credentials,username直接可以查看,凭证需要点击GENERATE NEW PASSWORD。
$ git config --global user.email "xx@xx.com"
$ git config --global user.name "xx"
$ git init
Initialized empty Git repository in G:/SourceCode/GitTest/learngit/.git/
查看隐藏文件ls –ah
$ ls -ah
./ ../ .git/
可以添加多个文件
$ git add main.c readme.txt
$ git commit -m"add 2 files"
[master (root-commit) cc6539b] add 2 files
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 main.c
create mode 100644 readme.txt
$ git reset --hard 142b883bd0d3f603180
HEAD is now at 142b883 The first modified
$ git branch
* master
XXX@DESKTOP-XXX MINGW64 /g/SourceCode/GitTest/learngit (master)
$ git checkout -b branch1
Switched to a new branch 'branch1'
XXX@DESKTOP-XXX MINGW64 /g/SourceCode/GitTest/learngit (branch1)
XXX@DESKTOP-XXX MINGW64 /g/SourceCode/GitTest/learngit (branch1)
$ git checkout master
Switched to branch 'master'
XXX@DESKTOP-XXX MINGW64 /g/SourceCode/GitTest/learngit (master)
注意不能删自己当前的分支。
XXX@DESKTOP-XXX MINGW64 /g/SourceCode/GitTest/learngit (branch2)
$ git branch -d branch1
Deleted branch branch1 (was 142b883).
A分支合并B分支内容
切换到A分支
Git merge B
$ git tag
tag1
$ git tag tag1
$ git tag -d tag1
Deleted tag 'tag1' (was 142b883)
git clone <版本库的网址>
git remote -v //查看修改前的仓库
git remote set-url origin xxx //xxx代表新的仓库地址
git remote -v //查看修改后的仓库
git pull
git fetch
区别:git pull = git fetch + git merge
$ git log -2
commit cc6539b3c45c4f146edbcaae242964aca6e7ec3f (HEAD -> master)
Author: xxx
Date: Tue Nov 29 11:03:47 2022 +0800
add 2 files
$ git config user.name
xxx
$ git config user.email
xx.xx@xx.com
$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
…