git常用操作

在本地创建分支(feature_1.0):

  • 基于当前分支创建并切换:git switch -c feature_1.0

  • 或基于指定分支创建:git switch -c feature_1.0 main

  • git rev-parse --is-inside-work-tree && git status -sb && git remote -v

  • git switch -c feature_1.0

  • git push -u origin feature_1.0

  • git status -sb

要将远程 main 分支合并到当前的 feature_1.0 分支,请按以下步骤执行:

1. 获取远程最新的更新

git fetch origin

2. 合并远程 main 分支到当前分支(feature_1.0)

git merge origin/main

3. 如果有冲突,解决冲突后执行:

git add .
git commit -m “merge: 合并 main 分支到 feature_1.0”

或者使用单条命令:
git pull origin main