eget无法提交代码到远程仓库

Yesterday, I posted a question on how to clone a Git repository from one of my machines to another,How can I 'git clone' from another machine?.

I am now able to successfully clone a Git repository from my source (192.168.1.2) to my destination (192.168.1.1).

But when I did an edit to a file, a git commit -a -m "test" and a git push, I get this error on my destination (192.168.1.1):

git push                                                
hap@192.168.1.2's password: 
Counting objects: 21, done.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1010 bytes, done.
Total 11 (delta 9), reused 0 (delta 0)
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
error: is denied, because it will make the index and work tree inconsistent
error: with what you pushed, and will require 'git reset --hard' to match
error: the work tree to HEAD.
error: 
error: You can set 'receive.denyCurrentBranch' configuration variable to
error: 'ignore' or 'warn' in the remote repository to allow pushing into
error: its current branch; however, this is not recommended unless you
error: arranged to update its work tree to match what you pushed in some
error: other way.
error: 
error: To squelch this message and still keep the default behaviour, set
error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To git+ssh://hap@192.168.1.2/media/LINUXDATA/working
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git+ssh://hap@192.168.1.2/media/LINUXDATA/working'

I'm using two different versions of Git (1.7 on the remote and 1.5 on the local machine). Is that a possible reason?


Answers

I just had the same error while I began learning Git. Some of the other answers are clearly not for someone new to Git!

(I am going to use non technical terms to get the idea across.) Anyway, what is happening is that you have two repositories, one is the original you first made, and the other the work one you just made.

Right now you are in your work repository and are using the "master" branch. But you also happen to be "logged in" in your original repository to the same "master" branch. Now since you're "logged in" in the original, Git fears you might mess up because you might be working on the original and screw things up. So you need to return to the original repository and do a "git checkout someotherbranch", and now you can push with no problems.

I hope this helps.


http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android Studio 是一个专为 Android 平台开发的集成开发环境(IDE),它可以用于开发 Android 应用、游戏和其他基于 Android 平台的软件。 Android Studio 的网页代码主要使用 HTML、CSS 和 JavaScript。其中,HTML 用于定义网页的内容结构,CSS 用于定义网页的样式和布局,JavaScript 用于实现网页的交互和动态效果。 在 Android Studio 中,可以使用 WebView 控件来加载和显示网页。WebView 是一个 Android 系统提供的控件,可以在应用中嵌入网页并与之交互。开发者可以通过 WebView 控件来实现许多功能,比如显示网页、执行 JavaScript 代码、处理网页的用户事件等。 以下是一个简单的网页代码示例: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>My Web Page</title> <style> body { background-color: #f0f0f0; font-family: Arial, sans-serif; } h1 { color: #000; text-align: center; } p { color: #333; font-size: 16px; line-height: 1.5; margin: 10px 0; padding: 0 20px; text-align: justify; } </style> </head> <body> <h1>Welcome to My Web Page</h1> <p>This is a sample paragraph. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget leo euismod, cursus lectus a, mollis tortor. Fusce euismod, sapien quis scelerisque tempor, ipsum sapien eleifend mauris, et porttitor massa dolor nec velit. Phasellus pulvinar ligula id ligula fringilla, a luctus nisi egestas. Nullam non odio vel felis iaculis pretium. Integer sit amet tellus eget nisl malesuada pharetra. Donec ac egestas velit, at vulputate risus.</p> </body> </html> ``` 以上代码定义了一个简单的网页,其中包括一个标题和一个段落。使用 CSS 定义了网页的样式,包括背景颜色、字体和排版等。在 Android Studio 中使用 WebView 控件可以将该网页加载到应用中并显示出来。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值