21

On github, I forked an old version of another project. I made some changes and am trying to push them onto my fork on github. I commited the changes locally, then tried git push, but this simply tells me "Everything up-to-date". When I browse the project on github, however, nothing has changed: it still shows the files (from the latest version) on my fork, unmodified. How can I push the changes to my github account?

(I realize this isn't much information...what else can I say? I have a feeling that it may be because I'm modifying the files directly in (home)/git/(project)...?)

4
  • 2
    Check if your are on correct branch. git log --graph --all --decorate --pretty=oneline and git remote show origin may be useful
    – tomgi
    Commented Jun 18, 2012 at 14:11
  • What is the output of git branch -v and git remote -v?
    – Stefan
    Commented Jun 18, 2012 at 14:13
  • 3
    Everything up-to-date means nothing has been pushed (because nothing has been added), did you git add and git commit before your git push? Commented Jun 18, 2012 at 14:24
  • Ahh, git branch -v indicates that my commit was on (no branch). As for the add, I initially commited the changes through Eclipse (with the git plugin)...when I do git add from the command line, it doesn't seem to do anything.
    – Kricket
    Commented Jun 18, 2012 at 14:25

6 Answers 6

12

git branch -v indicates that my commit was on (no branch). As for the add, I initially commited the changes through Eclipse (with the git plugin)...when I do git add from the command line, it doesn't seem to do anything

That means you are in a DETACHED HEAD mode.
You can add and commit, but from the upstream repo point of view (ie from the GitHub repo), no new commits are ready to be pushed.
You have various ways to include your local (detached HEAD) commit back into a branch, which you will be able to push then.
See:

The OP mentions this article in order to fix the situation:
"git: what to do if you commit to no branch"

all we need to do is checkout the branch we should have been on and merge in that commit SHA:

Note that instead of merging the SHA1 that you would have somehow copied, you can memorize it with a script, using head=$(git rev-parse HEAD):
See "git: reliably switching to a detached HEAD and then restore HEAD later, all from a script".
Then you can merge that detached HEAD back to the right branch.

2
  • Yep, this is what I just figured out. This showed me how to fix it.
    – Kricket
    Commented Jun 18, 2012 at 15:00
  • @KelseyRider I have added a reference to a script which would memorizing the detached HEAD SHA1 for you.
    – VonC
    Commented Jun 18, 2012 at 15:11
9

After you change files, you need to

git add

them prior to

git commit

.

1
  • 3
    He said he commited the changes locally
    – tomgi
    Commented Jun 18, 2012 at 14:28
5
git commit 

Will show you what files are on your local machine, uncomment what you want to upload and

git push origin master

Because git add * did not work for me (even if it didn't returned errors).

1
  • 3
    Instead of an asterisk (*), you use a period (.) to denote everything. Ex. git add .
    – Dan
    Commented Dec 12, 2018 at 14:05
2

Not sure why people are down voting the guy with the correct answer. For me adding my email and name did resolve the issue. Although the commands are not correct.

git config --global user.email "[email protected]"
git config --global user.name "Your Name"
0

Check the git commit -m command

In my case I had just forgotten to add the - before the m

When you do that the terminal outputs an error as follows
error: pathspec 'm' did not match any file(s) known to git
error: pathspec 'TESTING' did not match any file(s) known to git

But stil when you try to git push you won't get any error but the output will be

Everything up-to-date

The order should be:
git status

git add . Thats if you want to add the entire changes to be commited

git commit -m "Your Comments"

-2

In recent git version have to configer user details git config -g user.name "name"

git config -g user.email "[email protected]"

This resolved my problem

Not the answer you're looking for? Browse other questions tagged or ask your own question.