gpt4 book ai didi

Git 添加文件夹并推送

转载 作者:行者123 更新时间:2023-12-05 07:58:21 25 4
gpt4 key购买 nike

目前我在远程存储库中有这些文件:

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.

这是最新的错误消息。真实的 URL 被“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

最佳答案

开始喜欢

git init

然后,如果您正在读取任何文件或文件夹,则使用此命令执行

git add <file/folder name>

如果你要添加很多文件然后 git add . 也足以一次添加所有文件

然后提交文件

git commit -m "First commit"

然后像这样推送到分支

git push 

错误消息说文件与 repo 是最新的,所以 pull 和 rebase 会起作用

git pull 

git rebase

关于Git 添加文件夹并推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24945657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com