22

Sorry, I'm a git newbie (though I'm very familiar with older source control systems like cvs and svn) ...

My ultimate goal is to add a file to a remote repository (one not on my machine) by cloning that remote repository locally, adding the file to the local repository, committing my change, and then pushing my local repository back to the remote.

I tried this:

git clone ssh://user@server/Users/GitRepo/Project.git
<create file locally>
git add <localfile>
git commit -m "Narg"
git push

But it just says "Everything up to date".

So I tried going step-by-step, and got even more confused.

git clone ssh://user@server/Users/GitRepo/Project.git
git status

And it tells me

# Not currently on any branch
# Untracked files:
  followed by a long list of Untracked files.

Which seems really strange, why would the files be untracked if I just cloned the repository?

If it's important, the remote repository is brand-new, created via svn2git.

If I type

git remote show origin

it tells me

* remote origin
  Fetch URL: ssh://user@server/Users/GitRepo/Project.git
  Push  URL: ssh://user@server/Users/GitRepo/Project.git
HEAD branch: master
Remote branch:
   master tracked
Local branch configured for 'git pull':
   master merges with remote master
Local ref configured for 'git push':
   master pushed to master (up to date)

and if I type

git branch -a

it tells me

* (no branch)
master
remotes/GitRepo/master
remotes/origin/HEAD -> origin/master
remotes/origin/master

So am I just confused, and everything is actually working correctly? Or am I doing the git commands wrong? Or did I create the repository incorrectly, so no git commands will ever work properly?

Thanks, Chris

Betty Crokker
  • 3,001
  • 6
  • 34
  • 68
  • 2
    After `git clone ssh://user@server/Users/GitRepo/Project.git`, run the command `cd Project.git` before `git status` – Litmus Oct 24 '13 at 15:14
  • Hope `git checkout ` will help you – tijs Oct 24 '13 at 16:33
  • After git clone, I don't have a directory named Project.git - only a directory named Project that contains my actual files. So I'm getting a non-bare repository (right?). I can "cd .git" but running "git status" from there gives me the error "fatal: This operation must be run in a work tree" – Betty Crokker Oct 24 '13 at 22:19
  • sorry, it should be `cd Project`. That was a typo. You are right, you are cloning a non-bare repo. You need not get inside the `Project/.git` folder. You can run all git commands from the `Project` folder itself. Let `git` manage the `.git` folder. – Litmus Oct 25 '13 at 03:36
  • Possible duplicate: http://stackoverflow.com/questions/7705499/git-status-shows-untracked-file-on-a-higher-level – sactiw Apr 04 '16 at 06:53
  • 1
    I have just found the same thing. My main concern is not, as in the answers below, to properly track status, but why at all are untracked files even part of the repo. – ProfK Jun 14 '16 at 06:07
  • I faced with same situation. Solution was simple. In my repository was two folders with same name but different case. When I ran git clone, was loaded only one folder with uppercase name. Git status showed untracked files. So, rename or remove files and folders with same name. It happens when you share one repo on different OS. – Kirill A Jun 07 '19 at 10:58

5 Answers5

14

git config -l

if current git repository's core.precomposeunicode=true

try this,

git config core.precomposeunicode false

and this is why. from here

core.precomposeunicode This option is only used by Mac OS implementation of Git. When core.precomposeunicode=true, Git reverts the unicode decomposition of filenames done by Mac OS. This is useful when sharing a repository between Mac OS and Linux or Windows. (Git for Windows 1.7.10 or higher is needed, or Git under cygwin 1.7). When false, file names are handled fully transparent by Git, which is backward compatible with older versions of Git.

i-chou
  • 351
  • 2
  • 10
5

For others who may reach here by google.

I encountered the same issue - except that I was able to push and didn't get any "Everything up to date" message.
The problem was that windows and mac OS, unlike linux, are case-insensitive; but repo had been created on a case-sensitive OS and had got two version of some files differing only in capital and small letters.

There's an issue here about it.

hadi_sfr
  • 61
  • 1
  • 2
3

Git is a wonderful tool, but it's easy to get lost without a good map of where you are in the forrest of commits.

Here's how to get that map (I call it "gr" for "graph", but you could also call it "map" if you prefer):

git config --global alias.gr 'log --graph --full-history --all --color --decorate'

That's a one-time setup for git. Now whenever you're lost, just take a look at the map:

git gr

Your current location is denoted by the word "HEAD", and any branch names are also listed.

You'll see that you're currently not on any branch, which sounds a lot worse than it really is -- it's actually no big deal, it just means your commits won't go into the master branch the way you want them to.

So just get back on your master branch and commit there:

git checkout master
git add yourfile.txt
git commit -m'Narg'
git push

Also take a look at git gr now and you'll see that HEAD is at the same commit as master, and master is at the same commit as origin/master, which means you're all set.

Magnus
  • 10,736
  • 5
  • 44
  • 57
  • Thanks! Alas, my git newbieness is still causing problems ... the git graph shows the topmost revision is (HEAD, origin/master, origin/HEAD, GitRepo/master, master), how can I tell from that that I'm not currently on any branch? – Betty Crokker Oct 24 '13 at 21:48
  • And, if I say "git checkout master" from the root folder of my local repository, it either says "fatal: Unable to create '/Users/blah/blah/.git/index.lock': No space left on device" or "fatal: unable to write new index file" – Betty Crokker Oct 24 '13 at 21:56
  • "No space left on device" sounds like your hard disk is full? If you type df -h what does it say? For the other question, git gr won't actually tell you what branch you're on, only what commit you've currently checked out and what commits the existing branches point to (a branch is really nothing more than a pointer). for your current branch, you had the right command: git branch -a. – Magnus Oct 25 '13 at 04:10
2

Another reason this might happen: files with a colon in the name that were created in the github webinterface: lost:time.txt

eltjo
  • 31
  • 4
0

For me the main issue was with long paths set the git config to below then take checkout

git config --system core.longpaths true
Mahesh Hegde
  • 1,131
  • 10
  • 12