目前,我在远程存储库中有这些文件:
README
run.bat
MyCalories2 <-FOLDER THAT IS EMPTY BUT NEED TO HAVE PROJECT FILES
问题是MyCalories 2是一个文件夹,没有一个文件保存在Repo中。我尝试了X1 M0 N1 X,也尝试了从SourceTree添加这个文件夹,但它们根本没有上传到远程Repo。
$ git add .
$ git push -u origin master
Branch master set up to track remote branch master from origin.
Everything up-to-date
但是它不是!我如何将完整的文件夹添加到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.
这是最新错误消息真实的URL用'yyy'屏蔽
"马库斯我试过所有这些命令"
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
但是为什么会出现这种错误呢?
"有人帮忙吗,我被困在这里了"
最后是我的配置文件
[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
2条答案
按热度按时间wwwo4jvm1#
做与最初的像
然后如果你正在阅读任何文件或文件夹,那么用这个命令
或
如果您添加了很多文件,那么
git add .
也足以一次添加所有文件然后提交文件
然后推到分支上
错误消息显示文件与repo保持最新状态,因此pull和rebase可以正常工作
pexxcrt22#
好吧,现在手头的问题和原来的完全不同了......
从
git mergetool
的输出可以明显看出,MyCalories2:1.存在于远程存储库中。
1.实际上是远程仓库中的一个git submodule。
最有可能的是,您不应该只是用MyCalories2的库内副本替换该子模块。
你需要做的是
git clone
一个仓库的新副本,然后把你想提交的修改(如果有的话)从旧副本复制到新副本。然后请参见this answer了解如何在子模块中推送修改。