3

Currently I have those files in remote repository:

README 
run.bat 
MyCalories2 <-FOLDER THAT IS EMPTY BUT NEED TO HAVE PROJECT FILES

The problem is that MyCalories2 is a folder and none of the files are saved in repo. I tried with git add . and also tried adding this folder from SourceTree but they are simply never uploaded to the remote repo.

$ git add .
$ git push -u origin master
Branch master set up to track remote branch master from origin.
Everything up-to-date

but its not ! How do I add the complete folder to git ?

 ~/Dropbox/AndroidStudioProjects/test/xxx (master|MERGING)
$ git push -u origin master
Username for 'http://git.yyy.com': xxx
Password for 'http://yyy.com':
To http://git.yyy.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://yyy.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This is latest error msg. real URLs are masked with 'yyy'

@Marcus I tried all of these commands

ls -la . MyCalories2

MyCalories2:
total 15
drwxr-xr-x    1 Jalle    Administ     4096 Jul 25 21:46 .
drwxr-xr-x    1 Jalle    Administ     4096 Jul 25 21:49 ..
-rw-r--r--    1 Jalle    Administ       64 Jul 16 19:59 .gitignore
drwxr-xr-x    3 Jalle    Administ        0 Jul 25 14:37 .gradle
drwxr-xr-x   15 Jalle    Administ     4096 Jul 25 21:51 .idea
-rw-r--r--    1 Jalle    Administ      870 Jul 16 20:01 MyCalories2.iml
drwxr-xr-x    1 Jalle    Administ     4096 Jul 25 21:24 app
drwxr-xr-x    3 Jalle    Administ        0 Jul 25 14:37 build
-rw-r--r--    1 Jalle    Administ      452 Jul 24 21:33 build.gradle
drwxr-xr-x    3 Jalle    Administ        0 Jul 25 14:37 gradle
-rw-r--r--    1 Jalle    Administ      870 Jul 16 19:59 gradle.properties
-rwxr-xr-x    1 Jalle    Administ     5080 Jul 16 19:59 gradlew
-rwxr-xr-x    1 Jalle    Administ     2404 Jul 16 19:59 gradlew.bat
-rw-r--r--    1 Jalle    Administ      435 Jul 16 19:59 local.properties
drwxr-xr-x    5 Jalle    Administ        0 Jul 25 14:37 parseproj
-rw-r--r--    1 Jalle    Administ       16 Jul 16 19:59 settings.gradle


$ git --version
git version 1.9.4.msysgit.0

$ git pull
U       MyCalories2
M       run.bat
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.

$ git mergetool
Merging:
MyCalories2

Submodule merge conflict for 'MyCalories2':
  {local}: deleted
  {remote}: submodule commit 4bf1b974662b5b694f985ee93401227262fd3f26
Use (l)ocal or (r)emote, or (a)bort? l


$ git push -u origin master
Username for 'http://yyy.com': yyy
Password for 'http://yyy.com':
Counting objects: 245, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (215/215), done.
efrror: RPC failed; result=22, HTTP code = 4136.00 KiB/s
Watal: The remote end hung up unexpectedly
Writing objects: 100% (243/243), 1.29 MiB | 136.00 KiB/s, done.
Total 243 (delta 99), reused 0 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date

But why this error ?!?!

Any help, please ? I am stuck here !

and finally here is my config file

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    url = http://git.yyy.com/My-Name/My-Name.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[http]
    postBuffer = 524288000
[remote "ssh"]
    url = My-Name@yyy.com:My-Name/My-Name.git
    fetch = +refs/heads/*:refs/remotes/ssh/*
    pushurl = My-Name@yyy.com:My-Name/My-Name.git
Jalle
  • 99
  • 1
  • 1
  • 11
  • 2
    Did you do a `git commit` after the add? – Matthew Strawbridge Jul 24 '14 at 23:39
  • 1
    Might've been an idea to list that command too, since you carefully listed the others you ran. Your actual problem is that you're trying to add an *empty* folder. Don't think the original version of your question said that. – Matthew Strawbridge Jul 25 '14 at 21:48
  • 1
    ITs NOT empty directory. Why should I do that . Please remove this tag from my post. I am talking about complete project that I need to update. Why should I ever worry about empty folder ? – Jalle Jul 26 '14 at 07:15
  • 1
    Sorry, I read "folder that is empty" and assumed you meant "folder that is empty". – Matthew Strawbridge Jul 26 '14 at 17:36
  • 1
    I'm voting to close this question as off-topic because it's unclear and self-contradictory ("FOLDER THAT IS EMPTY" followed by a listing of extensive content in that folder) even after multiple edits by an OP who's long gone, last seen ~4 years ago. – jthill May 17 '18 at 00:52
  • 1
    Your problem is maybe related to [this one](https://stackoverflow.com/questions/7489813/github-push-error-rpc-failed-result-22-http-code-413). – Andreas Rau Jul 17 '18 at 12:14
  • hey, you miss `git commit` after `git add .` !! – Peyman Majidi Aug 12 '20 at 05:31

2 Answers2

0

Ok, now the issue at hand is a completely different one than originally...

From the output of git mergetool it's apparent that MyCalories2:

  1. exists in the remote repository.
  2. is actually a git submodule in the remote repository.

Most probably you should not just replace that submodule with your in-repository copy of MyCalories2.

What you need to do is git clone a fresh copy of the repository, then copy the changes you want to commit (if any) from your old copy to the new copy. Then please see this answer for info about how to push changes in a submodule.

Community
  • 1
  • 1
Marcus
  • 287
  • 2
  • 7
  • 1
    i updated question, those commands wont help either. STill cant add folder to repository – Jalle Jul 25 '14 at 08:25
  • 1
    Looks odd, but you need to provide some more info. What does `ls -la . MyCalories2` and `git --version` say? – Marcus Jul 25 '14 at 09:39
0

Do with initially like

git init

and then if you are reading any file or folder then do with this command

git add <file/folder name>

or

if you are adding lot of files then git add . also enough to add all files at once

then commit the files

git commit -m "First commit"

then push to the branch like

git push 

And the error message saying that the file up to date with repo so pull and rebase gonna work

git pull 

git rebase
Raja Simon
  • 10,126
  • 5
  • 43
  • 74