git reset --hard origin/master

git status FAQ: When I issue the "git status" command, I see the following "Your branch is ahead or origin/master ..." git message:

# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.
#
nothing to commit (working directory clean)

What does this "Your branch is ahead of 'origin/master' by X commits" message mean? I keep committing my changes with "git commit", so this message seems to be in error.

git status message - Your branch is ahead of 'origin/master' by X commits

These git "Your branch is ahead of origin/master" and "nothing to commit" messages can be misleading, especially to new git users (like myself). The thing to know here is that your branch isn't ahead of the the master -- your branch is the master.

What the git message is saying is that you're ahead of "origin/master", which (for new projects) is usually the branch on the remote git origin server. (You most likely did a "git clone" to get your git repository from the origin server.) So this message is telling you that you've made these changes, and you're now ahead of the origin server, and this message is essentially a reminder to push your changes back to the origin server.

If you're working on a simple project (like I am) you can push your changes back to the origin server with this command:

git push origin master

Git commit is not "cvs commit" or "svn commit"

Frankly, this is something I'm really struggling with regarding Git right now. I'm used to "cvs commit" or "svn commit" committing my changes back to the server, but with Git this is a multi-step step process, as shown here:

# make your changes
$ git add .
$ git commit -m 'your message'
$ git push origin master

If you forget that last step -- which I always do -- you'll see the

"Your branch is ahead of origin/master by X commits" git status message, along with the "nothing to commit" message (again, reminding you to do a "git push").

git status message - Your branch is ahead of origin/master by X commits的更多相关文章

  1. Your branch is ahead of 'origin/master' by 21 commits.

    当切换到主分支后,准备 git pull 拉取远程 master 分支时,提示本地主分支显示有 21 个commits 问题原因: 因为你修改了 local master 本地的主分支,可以选择以下方 ...

  2. Git Your branch is ahead of 'origin/master' by X commits解决方法

    (1)方法1:git fetch origin (2)方法2(代码还需要):git push origin (3)方法3 (代码不需要):git reset --hard origin/$branch ...

  3. Your branch is ahead of 'origin/master' by 2 commits.

    遇到这种问题,表示在你之前已经有2个commit而没有push到远程分支上,所以需要先git push origin **将本地分支提到远程仓库.也可以直接git reset --hard HEAD~ ...

  4. Git报错:Your branch is ahead of 'origin/master' by 1 commit

    .    commit之后,用git status,打印信息为: # On branch master # Your branch is ahead of 'origin/master' by 1 c ...

  5. Your branch is ahead of 'origin/master' by 1 commit.

    git reset HEAD^ --soft git reset HEAD^ --hard --soft 表示保留当前commit,重新commit --hard 表示丢弃当前add,重新add.co ...

  6. git pull 然后 ahead of origin/master * commit 消失

    本来显示 your branch is ahead origin/master * commit后来也许在master merge 这个分支后, 然后git pull, 就显示Your branch ...

  7. it commit提示Your branch is up-to-date with 'origin/master'.

    今天提交git仓库的时候,遇到了如截图所示的问题,提示Your branch is up-to-date with 'origin/master'. 查了些资料后,发现其根本原因是版本分支的问题 这时 ...

  8. Git Push:error: Couldn't set refs/remotes/origin/master;error: update_ref failed for ref 'refs/remot

    作者:荒原之梦 原文链接:http://zhaokaifeng.com/?p=543 今天使用Git Push代码时产生错误: Rename from 'XXXX/.git/refs/remotes/ ...

  9. git status: HEAD detached from origin/master问题的解决

    问题:执行git status,提示: HEAD detached from origin/master 原因:分支选错了,后续的提交都提交到了一个匿名分支之上,整个状态是游离了的 解决方法: 1.查 ...

随机推荐

  1. G面经prepare: set difference

    给你A{1,2,3,4,4,5}, B{2,4},求A-B={1,3,4,5},很简单. visit 1 只用一个HashMap package TwoSets; import java.util.* ...

  2. [转]Java多线程干货系列—(一)Java多线程基础

    Java多线程干货系列—(一)Java多线程基础 字数7618 阅读1875 评论21 喜欢86 前言 多线程并发编程是Java编程中重要的一块内容,也是面试重点覆盖区域,所以学好多线程并发编程对我们 ...

  3. oracle 新手遇到常见问题的解决办法

    可能照成以下问题的原因也许有很多种,但是就小白而言,我只记录自己学习过程中遇到的所有的问题.希望对一些新手 小白们有所帮助. 原因是 sys 不是sysdba 用户,你要将其作为sysdba 用户登录 ...

  4. C++之路进阶——codevs4655(序列终结者)

    4655 序列终结者  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 大师 Master      题目描述 Description 网上有许多题,就是给定一个序列,要你支持几 ...

  5. 使用PHP发送邮件

    使用封装SMTP协议的邮件类 使用PEAR扩展中的Mail类,功能强大:可以支持纯文本.HTML格式的邮件:各字段都可设置编码,正确配置不会出现中文乱码情况:可以支持附件等等. 在服务器可以使用 pe ...

  6. cannot modify header information 关于实现widget页面跳转的问题

    查找网上解决此问题的方法多是一样的,不过今天又遇到了这样的问题.试过之后发现可行: 在C盘的WINDOWS或者你的PHP文件夹中找到php.ini 这个配置文件,然后查找一项:output_buffe ...

  7. C# 控制台程序如何防止启动多个实例

    ==================================================================================================== ...

  8. Oracle Savepoint

    1.目的: Use the SAVEPOINT statement to identify a point in a transaction to which you can later roll b ...

  9. 夺命雷公狗---DEDECMS----16dedecms取出首页今日更新

    我们这次就要来取出我们的电影和电视剧以及综艺节目: 我们首先在我们受页面的模版文件中获取电影和电视剧的标签: 我们发现这里有一大堆,我只留一个即可: 然后我们到后台更新下首页的模版,看下是否只有一个模 ...

  10. Oracle中的rownum用法解析

    注意:rownum从1开始:  1.rownum按照记录插入时的顺序给记录排序,所以有order by的子句时一定要注意啊!  2.使用时rownum,order by字段是否为主键有什么影响?  3 ...