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

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

二,加入本地改动

git add 文件名称(多个文件名称以空格隔开)

三,推送全部改动

git commit -a -m '这是凝视'

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

四,拉取远程更新

git pull

此处会提示你输入账户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 '凝视'

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

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

git commit -a -m '凝视'

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

git reset --hard
git pull

几个经常使用的命令:

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

git checkout . #本地全部改动的。

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

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

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

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





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

相关文章
|
Linux 开发工具 C语言
Linux的学习之路:7、yum与git
Linux的学习之路:7、yum与git
156 0
|
4月前
|
Linux 开发工具 git
解决 Linux git push 成功后(但没有出现绿点)的问题
最近学习使用Git,发现有时候在Linux下提交自己的小绿点并没有增加,单在仓库中却可以看到提交的代码。看着连续的绿点中出现几个零零散散的灰点,着实让一个强迫症患者十分难受。接下来分享以下我所知道的问题。
83 0
|
6月前
|
安全 Linux 网络安全
在Linux(CentOS和AWS)上安装更新的git2的方法并配置github-ssh
经过以上这些步骤,你现在就能在GitHub上顺利往返,如同海洋中的航海者自由驰骋。欢迎你加入码农的世界,享受这编程的乐趣吧!
226 10
|
7月前
|
Linux iOS开发 MacOS
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
167 0
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Git 服务
|
Linux 开发工具 git
linux自建仓库git之钩子不生效
linux自建仓库git之钩子不生效
|
存储 Linux 开发工具
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
119 1
|
JavaScript Ubuntu Linux
蓝易云 - linux中安装nodejs,卸载nodejs,更新nodejs,git
请根据自己的Linux发行版和版本选择合适的命令。
380 2
|
Linux 测试技术 开发工具
CentOS Linux 8使用阿里源(安装jdk11、git测试)
CentOS Linux 8使用阿里源(安装jdk11、git测试)
1558 1
|
Linux 开发工具 git
解决 Linux git push 贡献者不同(没有出现绿点)的问题
解决 Linux git push 贡献者不同(没有出现绿点)的问题
|
NoSQL Linux 开发工具
【Linux】Linux开发工具(yum、gdb、git)详解
【Linux】Linux开发工具(yum、gdb、git)详解