Git使用

该文介绍了Git的基本使用流程,包括初始化仓库、添加文件、提交更改、查看差异、分支管理、合并冲突、推送与拉取远程分支、使用stash暂存更改以及如何进行软重置和变基操作。内容涵盖了从创建新功能分支到合并回主分支的完整开发流程。
摘要由CSDN通过智能技术生成

文件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、付费专栏及课程。

余额充值