Git使用

文件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 变基

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值