Git工具

git 相关命令操作:

a) git创建仓库:
git init # 初始化一个git仓库,会生成.git文件
git init newdir # 会在newdir目录下生成一个.git文件
# 配置全局git代理
git config --global http.proxy http://user:password@proxy.xxx.com:8080
git config --global https.proxy http://user:password@proxy.xxx.com:8080
#设置提交代码时的用户信息:
git config --global user.name "runoob"
git config --global user.email test@runoob.com

b) git基本操作
git clone xxx # 拷贝远程仓库,即下载一个项目
git add [file1] [file2] # 向暂存区添加2个文件
git add [dir] # 向暂存区添加目录
git add . # 将当前目录全部添加到暂存区
git commit -m "评论内容" # 将暂存区内容添加到仓库中
git push <远程主机名> <本地分支名> / git push origin master # 将本地master分支推送到origin主机的master分支
git pull # 下载远程代码并合并
git log # 查看历史提交记录
git status # 查看是否对文件有修改
git diff [fiel] # 查看暂存区文件和工作区文件的差异,指具体内容差异
git reset HEAD^ # 回退所有内容到上一个版本

git config -l
git config --global --list # 用于查看基本配置

c) git分支管理

git branch (branchname) # 创建分支branchname
git push --set-upstream origin username # 将branch分支上传到远程服务器
git checkout (branche) # 切换分支
git merge # 合并分支

git branch # 查看本地分支
git branch -r #查看远程分支

posted @ 2022-06-24 17:05  宇宙刘  阅读(44)  评论(0)    收藏  举报