文件hello.c
在文件夹内git init新建一个git仓库
git add hello.c追踪此文件
git commit 将其暂存
#
git diff可以查看文件被修改的详细情况
git log 可以查看提交历史
git remote add name(origin) https.git
#
git branch name
git checkout name
git branch --list
#
git merge feature1
git log --all --graph
git merge feature2
冲突
git status看哪里有冲突
进入文件,==上是当前分支,下是想要合并的修改
修改文件后退出,add commit
这时候就合并了
```
# Start a new feature
git checkout -b new-feature main
# Edit some files
git add <file>
git commit -m "Start a feature"
# Edit some files
git add <file>
git commit -m "Finish a feature"
# Merge in the new-feature branch
git checkout main
git merge new-feature//git merge --no-ff <branch>(有commit标记)
git branch -d new-feature
```
三路合并
```
Start a new feature
git checkout -b new-feature main
# Edit some files
git add <file>
git commit -m "Start a feature"
# Edit some files
git add <file>
git commit -m "Finish a feature"
# Develop the main branch
git checkout main
# Edit some files
git add <file>
git commit -m "Make some super-stable changes to main"
# Merge in the new-feature branch
git merge new-feature
git branch -d new-feature
```
也可以先将feature变基到main再快速合并
#
git push origin master推送到远端
git push -u origin master一次可以省略仓库与分支名push
#
git fetch
git checkout 远程分支
可以把远程的分支都拉下来到本地
#
git stash
git stash list
git stash apply
git stash apply stash@{number}
#
git reset head~num --soft
~num
--soft只重置commit
#
git rebase 变基