git 在linux中的使用

简介:

1,经常使用操作

一,clone远程仓库 比如clone test项目的分支v1.0

git -c diff.mnemonicprefix=false -c core.quotepath=false clone --branch v1.0 https://git.oschina.net/test.git /Users/test
AI 代码解读

这部分运行之后会提示你输入仓库的账号password

二,加入本地改动

git add 文件名称(多个文件名称以空格隔开)
AI 代码解读

三,推送全部改动

git commit -a -m '这是凝视'
AI 代码解读

-a代表 all 。-m代码 message凝视

四,拉取远程更新

git pull
AI 代码解读

此处会提示你输入账户password

2,常见错误

1。git pull时出现下面错误:error: Your local changes to the following files would be overwritten by merge:

这是本地与远程仓库之间出现了版本号冲突,这时我们先隐藏本地改动,再拉取远程更新,然后恢复本地改动,最后再提交:

git stash
git pull
git stash pop
git commit -a -m '凝视'
AI 代码解读

2,git pull时出现下面错误:Pull is not possible because you have unmerged files.

事实上是错误1的延续。忘了运行git commit -a -m 这一步就直接又git pull 须要再次运行:

git commit -a -m '凝视'
AI 代码解读

假设希望用代码库中的文件全然覆盖本地工作版本号. 方法例如以下:

git reset --hard
git pull
AI 代码解读

几个经常使用的命令:

1.rm 删除文件
2.git checkout xxx(还原某文件)
等冲突都解决后,再pull

git checkout . #本地全部改动的。
AI 代码解读

没有的提交的,都返回到原来的状态 git stash #把全部没有提交的改动暂存到stash里面。可用git stash pop回复。

git reset --hard HASH #返回到某个节点。不保留改动。

git reset --soft HASH #返回到某个节点。保留改动

以上方法都须要在git项目文件夹中运行





本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5284804.html,如需转载请自行联系原作者

目录
打赏
0
0
0
0
56
分享
相关文章
Linux的学习之路:7、yum与git
Linux的学习之路:7、yum与git
97 0
|
1月前
|
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
48 0
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
蓝易云 - linux中安装nodejs,卸载nodejs,更新nodejs,git
请根据自己的Linux发行版和版本选择合适的命令。
291 2
CentOS Linux 8使用阿里源(安装jdk11、git测试)
CentOS Linux 8使用阿里源(安装jdk11、git测试)
787 1
解决 Linux git push 贡献者不同(没有出现绿点)的问题
解决 Linux git push 贡献者不同(没有出现绿点)的问题
【Linux】Linux开发工具(yum、gdb、git)详解
【Linux】Linux开发工具(yum、gdb、git)详解
linux 搭建git仓库 git代码仓库 (小团队内部合作)
linux 搭建git仓库 git代码仓库 (小团队内部合作)
523 1

热门文章

最新文章