目前我在远程存储库中有这些文件:
README
run.bat
MyCalories2 <-FOLDER THAT IS EMPTY BUT NEED TO HAVE PROJECT FILES
问题是MyCalories2是一个文件夹,没有任何文件保存在repo中。
我尝试使用git add .
并尝试从SourceTree添加此文件夹,但它们从未上传到远程仓库。
$ 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.
这是最新的错误消息。真实的网址被'yyy'掩盖
@Marcus我尝试了所有这些命令
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
答案 0 :(得分:0)
好的,现在手头的问题与最初的问题完全不同......
从git mergetool
的输出中可以明显看出MyCalories2:
很可能你应该不只用存储库副本替换该子模块 MyCalories2。
您需要做的是git clone
存储库的新副本,然后将您要提交的更改(如果有)从旧副本复制到新副本。然后,请参阅this answer,了解有关如何推送子模块中的更改的信息。
答案 1 :(得分:0)
最初喜欢
git init
然后如果您正在阅读任何文件或文件夹,请使用此命令
git add <file/folder name>
或
如果您要添加大量文件,那么git add .
也足以一次添加所有文件
然后提交文件
git commit -m "First commit"
然后按
推送到分支git push
错误消息说文件最新与repo如此拉动和rebase将工作
git pull
git rebase