笔头云 笔头云
首页
设计模式
SQL教程
Redis
归档
关于
友链

笔头云

非淡泊无以明志,非宁静无以致远。
首页
设计模式
SQL教程
Redis
归档
关于
友链
  • JsonProperty
  • Git常用命令
    • 获取帮助
    • 常用命令
    • 分支管理
      • 建立分支并关联远程分支
      • 从某次提交创建分支
    • 远程仓库
    • Git仓库
      • 1. 克隆远程仓库
      • 2. 创建本地仓库
  • Office Util办公工具
  • FRP内网穿透docker部署
  • 后端
笔头云
2024-01-16
目录

Git常用命令

# 获取帮助

git help # 获取帮助
git help command # 获取指定命令的帮助
git command -h # 获取指定命令的简明帮助
1
2
3

# 常用命令

git status # 查看git库状态
git pull # 拉取代码
git add . # 添加代码到暂存区
git commit -m "注释"  # 提交代码到本地仓库
git push # 推送代码到远程仓库
git diff file-name # 对比文件修改内容(已暂存和未暂存对比)
git log [-p] [--pretty=oneline] # 查看提交历史[显示提交的差异] [单行显示]

1
2
3
4
5
6
7
8
git add

add是个多功能命令:可以用它开始跟踪新文件,或者把已跟踪的文件放到暂存区,还能用于合并时把有冲突的文件标记为已解决状态等。 将这个命令理解为“精确地将内容添加到下一次提交中”而不是“将一个文件添加到项目中”要更加合适。

# 分支管理

git branch [-a] # 查看当前分支[所有分支]
git checkout branch-name # 切换到指定分支
git checkout -b new-branch-name # 创建并切换到新分支
git merge branch-name # 合并指定分支到当前分支
git branch -d branch-name # 删除指定分支
git cherry-pic commit-id # 将某个分支的某次提交应用到当前分支
1
2
3
4
5
6

# 建立分支并关联远程分支

git checkout -b develop
git branch --set-upstream-to=origin/develop develop
1
2

# 从某次提交创建分支

# 查看提交日志
git log
# 从某次提交创建新分支
git checkout commit-id -b new-branch-name
# 提交到仓库
git push origin new-branch-name
1
2
3
4
5
6

# 远程仓库

git remote [-v] # 查看远程仓库[对应的url]
git remote add short-name url # 添加远程git仓库
git push origin master # 推送到远程仓库
1
2
3

# Git仓库

# 1. 克隆远程仓库

git clone code-address  # 克隆代码
git clone -b branch-name code-address  # 克隆指定分支代码
git clone code-address new-name # 克隆代码并重命名目录名称
1
2
3

# 2. 创建本地仓库

cd directory-name # 进入指定目录
git init # 初始化本地仓库
git add file # 添加文件到暂存区
git commit -m "注释" # 提交到本地仓库
1
2
3
4
上次更新: 2024/01/16, 13:25:25
JsonProperty
Office Util办公工具

← JsonProperty Office Util办公工具→

最近更新
01
FRP内网穿透docker部署 工具
05-07
02
Office Util办公工具 工具
01-14
03
JsonProperty
12-25
更多文章>
Theme by Vdoing | Copyright © 2023-2025 鲁ICP备2023014898号 公安备案号:37020302372159
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×