2.git 基础命令

0.安装好docker 后 启动/停止

systemctl start docker  #启动docker服务
systemctl stop docker  #关闭docker服务
sudo systemctl stop docker.socket

1.查看git 配置

 git config -l 查看所有配置
 git config --system --list 查看系统配置
 存放路径为:D:\javaBeans\Git\etc\gitconfig 文件里
 git config --global --list 查看用户全局配置
 存放路径为:D:\MyData\huangchong7

注:所有的配置文件都保存在本地

huangchong7@huangchong7987 MINGW64 ~/Desktop
$ git config -l
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=D:/javaBeans/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager
user.name=hc7
user.email=hc7@qq.com
huangchong7@huangchong7987 MINGW64 ~/Desktop
$ git config --system --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=D:/javaBeans/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
credential.helper=manager

huangchong7@huangchong7987 MINGW64 ~/Desktop
$  git config --global --list
user.name=hc7
user.email=hc7@qq.com

2.设置git全局配置

git config --global user.name "hc7"
git config --global user.email "hc7.qq.com"

注:不配置此用户配置,不能使用git 提交

3.查看文件git 状态

git status

4.1 git init 初始化git项目/git clone 远程项目

git init
或
git clone <项目url>

4.2git add . 添加所有文件到暂存区

git add .

5.git commit 提交到本地仓库

git commit -m "我的第一次提交"
#-m “msg” :提交信息的备注

6.git 的忽略文件
在仓库目录下新建一个名为.gitignore的文件(因为是点开头,没有文件名,没办法直接在windows目录下直接创建,必须通过右键Git Bash,按照linux的方式来新建.gitignore文件)。如下图所示。

vim .gitignore

在这里插入图片描述
忽略文件规则:

 *.txt # 忽略所有txt文件
 !lib.txt # lib.txt文件除外
 *.[oa] # 忽略*.o和*.a文件

# 忽略*.b和*.B文件,my.b除外
*.[bB]
!my.b

# 忽略dbg文件和dbg目录
dbg

# 只忽略dbg目录,不忽略dbg文件
dbg/

# 只忽略dbg文件,不忽略dbg目录
dbg
!dbg/

# 只忽略当前目录下的dbg文件和目录,子目录的dbg不在忽略范围内
/dbg

/temp #仅忽略项目根目录下的TODO文件,但不包括其他目录temp
build/ #忽略build/目录下的所有文件
doc/*.txt #忽略doc/notes.txt文件,但不包括doc/server/notes.txt

eg: 项目中实际的gitignore 大致如下

target/
/bin/
/.settings/
.classpath
.project
*.iml
.idea/

7.git 分支命令

git branch #列出所有本地分支
git branch -r #列出所有远程分支
git -[branch-name] #新建一个分支,但依然停留在当前分支
git checkout -b [branch-name] #新建一个分支,并切换到该分支
git merge [branch]#合并指定分支到当前分支
git branch -d [branch-name] #删除分支
#删除远程分支
git push origin --delete [branch-name] 
git branch -dr [remote/branch] 

8.当前git用户获取与操作

获取当前登陆用户:
git config user.name   //获取当前登录的用户
git config user.email  //获取当前登录用户的邮箱
修改登陆用户:
git config --global user.name 'userName'    // 修改登陆账号,userName为你的git账号
git config --global user.email 'email'      // 修改登陆邮箱,email为你的git邮箱
git config --global user.password 'password'  // 修改登陆密码,password为你的git密码
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值