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. PostgreSQL Replication之第十二章 与Postgres-XC一起工作(3)

    12.3 配置一个简单的集群 在本章中,我们要建立一个由三个数据节点组成的集群.一个协调节点,以及管理集群的全局事务管理节点.对于每个组件,我们必须创建一个目录: hs@vm:~/data$ ls - ...

  2. G面经Prepare: Search word delete sequence in dictionary

    给一个单词一个字典,每次删除单词里任一个字母直到剩下一个字母,形成一个序列,比如office->offce->ofce->ofc->oc->c.问是否字典里存在一个这种序 ...

  3. 数dp多少个0-n多少0-9

    #include <bits/stdc++.h> using namespace std; const int N = 15; int n; int dp[N][N][N]; int a[ ...

  4. Splay!

    #include<cstdio> #include<cstdlib> ; ; ; int lim; struct SplayTree { . int sz[maxn]; . ] ...

  5. EJS 是什么 ,怎么用,以及优点

    一.什么是EJS EJS是一个JavaScript模板库,用来从JSON数据中生成HTML字符串. 二.为什么要使用EJS 与最初的JavaScript相比较,一些不太了解你的代码的人可以更容易地通过 ...

  6. JQuery下CheckBox全选全不选反选

    <script src="JS/jquery-1.7.1.js"></script> <script type="text/javascri ...

  7. Java基础(2):Java中的四个跳转语句总结goto,break,continue,return

    跳转控制语句 Java中的goto是保留字,目前不能使用.虽然没有goto语句可以增强程序的安全性,但是也带来很多不便,比如说,我想在某个循环知道到某一步的时候就结束,现在就做不了这件事情.为了弥补这 ...

  8. AJax 学习笔记二(onreadystatechange的作用)

    AJax 学习笔记二(onreadystatechange的作用) 当发送一个请求后,客户端无法确定什么时候会完成这个请求,所以需要用事件机制来捕获请求的状态XMLHttpRequest对象提供了on ...

  9. mysql 行锁

    在电子商务里,经常会出现库存数量少,购买的人又特别多,大并发情况下如何确保商品数量不会被多次购买. 其实很简单,利用事务+for update就可以解决. 我们都知道for update实际上是共享锁 ...

  10. js break continue

    for 循环从 1 到 10 迭代变量 i.在循环主体中,if 语句将(使用取模运算符)检查 i 的值是否能被 5 整除.如果能被 5 整除,将执行 break 语句.alert 显示 "4 ...