posts - 339,  comments - 95,  views - 178万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

1. 取消 merge

1) 先用 git reflog 查看操作日志

2) 使用 git reset --hard HEAD@{x} 强制回到你需要的分值 

 

2. 创建新分支

git checkout -b newBranch

 

3. 提交到远程分支

git push origin newBranch

 

4. 将本地分支指向远程分支

git push -u origin newBranch

 

5. 将当前分支提交到新分支

git push origin HEAD:newBranch

 

6. 批量取消 add

例如批量取消 .iml 文件的 add

git reset HEAD $(git ls-files | grep .iml)

 

7. 暂存当前修改

git stash 暂存当前修改

切换到其他分支, 修改, 切回原来分支

git stash list 查找暂存内容

git stash apply stash@{1} 恢复暂存内容

 

8. 显示远程服务信息

git remote show origin

origin 为远程 repository 名

 

9. 添加远程分支

git remote add <别名> <url>

 

10. 初始化项目

复制代码
# 克隆项目到本地
git clone git@gitlab.corp.qunar.com:campus2015/training2.git

# 切换到 training2
cd training2

# 新建分支并切换到新的分支, 现在这个分支在本地, newBranch 是分支名, 请根据自己的需要命名自己的分支
git checkout -b newBranch

# 回到上一级目录
cd ..

# mvn 初始化项目, 这一步可能会比较慢, 可以使用 idea 新建项目替代这一步
mvn archetype:generate -DgroupId=com.qunar.training -DartifactId=training2 -Dversion=1.0.0 -DinteractiveMode=false -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=5-SNAPSHOT

# 进入项目目录
cd training2

# 添加本地未添加的文件 pom.xml 和 src 文件夹
git add pom.xml src

# 提交一次
git commit -m 'first commit'

# push 到远程分支 newBranch
git push -u origin newBranch
复制代码

 

 

posted on   ZimZz  阅读(664)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示