Reputation: 8596
I just commited my working tree, added to index first, with "$git commit -m 'test'" I saved the stdout-put from this to a file and I see at the top of it that it says
# On branch master
# Changed but not updated:
# (use "git add/rm ..." to update what will be commited)
# (use "git checkout -- ..." to discard changes in working directory)"
the problem is that my working tree is not being commited to the repo, and I have a feeling this has something to do with it
thanks
Upvotes: 26
Views: 71299
Reputation: 11598
git push -u origin master
You're most likely trying to push commits to a branch that wasn't created yet - for example, on a newly created Github repository without the README file automatically created. By calling git push -u origin master
, you specify both the remote that you need to push to (origin, which is usually the git default) and the branch (master, also default in typical cases). According to the git documentation:
-u, --set-upstream For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch..merge in git-config(1).
This means that after a successful run of this command, from then on you'll be able to just use git push
and git pull
and it will default to origin master
(with some exceptions).
Upvotes: 29
Reputation: 2650
Guys I had the same problem with Git.
I am running Cygwin on windows 8.
$ git remote -v
# this is how you can see your path
$ git remote set-url origin [email protected]:username/repos.git
# this is how you set new path remotely to push files to the right repository.
$ git remote -v
# to check if the right path was set.
$ git add .
4.
$ git push origin master
HOPE THIS HELPS
Upvotes: 0
Reputation: 11596
If you move files around and use git add
afterwards, git only adds the new copy, but doesn't remove the old one:
$ git status
# On branch master
nothing to commit (working directory clean)
$ mv from to
$ git add .
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: to
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: from
#
$ git commit -m "..."
$ git status
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: from
#
no changes added to commit (use "git add" and/or "git commit -a")
To remove the old copies you should also use git rm
:
$ git rm from
rm 'from'
$ git commit -m "..."
$ git status
# On branch master
nothing to commit (working directory clean)
But I don't see why it doesn't allow you to commit those changes.
Upvotes: 0
Reputation: 6734
Did you do a git add .
before you committed?
It's always wise to do a git status
before either git add
or git commit
to see what's changed and staged, as well.
It's also very handy to do git diff
to see the specific changes you are about to commit.
Here's what git status
shows if you have added a file and then renamed it.
me@home:~$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: foo.txt
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: foo.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# bar.txt
At this point you can just do git add .
and then git status will give you more information, perhaps pointing out that you still have a new file and a deleted file called
foo.txt. To fix this you need to manually
git rm foo.txtbefore doing
git commit`
In the future if you have files in a git repo that you want to move you should use git mv
.
Upvotes: 2
Reputation: 1161
One other thing to note, git add adds the content of those files to the index at the time when you run it. If you run git add and then change the files, the new changes will not show up in the index.
Upvotes: 1
Reputation: 15974
You really have to read the documentation.
git add yourfile
git commit -m "test"
Or, to commit all changed files --
git commit -a -m "test"
Upvotes: 0
Reputation: 64650
Before you commit a change, you must add it to the index first:
git add myfile
git commit -m "test"
Alternatively, you can work in a more SVN-like style and commit everything that is changed:
git commit -a -m "test"
Or you can just add-and-commit a single file:
git commit myfile -m "test"
Upvotes: 6