i漂泊

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 4883|回复: 2

git常见问题集锦

[复制链接]
TA的礼物信息
  • 收到:0
  • 送出:2
发表于 2015-8-6 20:47:50 | 显示全部楼层 |阅读模式
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.


解决方法:
Edit your .git/config
  1. [branch "master"]  remote = origin  merge = refs/heads/master
复制代码


error: Your local changes to the following files would be overwritten by merge:
nbproject/private/private.xml
Please, commit your changes or stash them before you can merge.
Aborting


解决方法:
http://blog.csdn.net/lincyang/article/details/21519333

1.stash
通常遇到这个问题,你可以直接commit你的修改;但我这次不想这样。
看看git stash是如何做的。
  1. <div>git stash</div><div>git pull</div><div>git stash pop</div>
复制代码


接下来diff一下此文件看看自动合并的情况,并作出相应修改。
git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。
git stash pop: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。
git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。

2.放弃本地修改,直接覆盖之
  1. <div>git reset --hard</div><div>git pull</div>
复制代码

error: Untracked working tree file 'public/images/icon.gif' would be overwritten by merge.

需要执行下面的命令才能修复:


git reset --hard HEAD   
git clean -f -d   
git pull  



回复

使用道具 举报

TA的礼物信息
  • 收到:0
  • 送出:2
 楼主| 发表于 2015-9-23 13:13:19 | 显示全部楼层
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.


解决方案:
  1. rm -f ./.git/index.lock
复制代码
回复 支持 反对

使用道具 举报

TA的礼物信息
  • 收到:0
  • 送出:2
 楼主| 发表于 2015-10-13 09:53:30 | 显示全部楼层
  1. There is no tracking information for the current branch.
  2. Please specify which branch you want to merge with.
  3. See git-pull(1) for details

  4.     git pull <remote> <branch>

  5. If you wish to set tracking information for this branch you can do so with:

  6.     git branch --set-upstream-to=origin/<branch> master
复制代码



看到第二个提示,我们现在知道了一种解决方案。也就是指定当前工作目录工作分支,跟远程的仓库,分支之间的链接关系。<br>
<br>
比如我们设置master对应远程仓库的master分支<br>
<br>
git branch --set-upstream master origin/master<br>
<br>
这样在我们每次想push或者pull的时候,只需要 输入git push 或者git pull即可。<br>
<br>
在此之前,我们必须要指定想要push或者pull的远程分支。<br>

git push origin master<br>

git pull origin master.<br>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|IPiaoBo Inc. ( 渝ICP备17002826号 )

GMT+8, 2024-5-2 12:14 , Processed in 0.059179 second(s), 54 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表