Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Version control 正在将包含图像的文件夹上载到github_Version Control_Github_Directory - Fatal编程技术网

Version control 正在将包含图像的文件夹上载到github

Version control 正在将包含图像的文件夹上载到github,version-control,github,directory,Version Control,Github,Directory,正如标题所述,我正在将我的项目上传到github(),但我被困在这里了。我不能上传一个名为img的目录到github,有人能帮我怎么做吗。我没有使用任何gui。我可以像创建新文件那样在github.com中创建新文件夹吗 这就是正在发生的事情: siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git@github.com:siddhartha-ramesh/FilmRevi

正如标题所述,我正在将我的项目上传到github(),但我被困在这里了。我不能上传一个名为img的目录到github,有人能帮我怎么做吗。我没有使用任何gui。我可以像创建新文件那样在github.com中创建新文件夹吗

这就是正在发生的事情:

siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git@github.com:siddhartha-ramesh/FilmReview.git
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ cd ~
siddhartha@siddhartha-Inspiron-545s ~ $ cd .ssh
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ ssh-keygen -t rsa -C "siddhartharamesh@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/siddhartha/.ssh/id_rsa): key
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in key.
Your public key has been saved in key.pub.
The key fingerprint is:
#key here
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ cd /home/siddharhta/.ssh
bash: cd: /home/siddharhta/.ssh: No such file or directory
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ cd /home/
siddhartha@siddhartha-Inspiron-545s /home $ cd *
siddhartha@siddhartha-Inspiron-545s ~ $ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
siddhartha@siddhartha-Inspiron-545s ~ $ cd ..
siddhartha@siddhartha-Inspiron-545s /home $ ls
siddhartha
siddhartha@siddhartha-Inspiron-545s /home $ cd siddhartha/
siddhartha@siddhartha-Inspiron-545s ~ $ cd .ssh
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ ls
key  key.pub  known_hosts
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ cat key
-----BEGIN RSA PRIVATE KEY-----
-----END RSA _________________
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ ls -a
.  ..  key  key.pub  known_hosts
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ cat key.pub
ssh-rsa 
#key here
siddhartha@siddhartha-Inspiron-545s ~/.ssh $ cd ..
siddhartha@siddhartha-Inspiron-545s ~ $ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
siddhartha@siddhartha-Inspiron-545s ~ $ cd Desktop/
siddhartha@siddhartha-Inspiron-545s ~/Desktop $ ls 
Aptana_Studio_3  C_C++  Codes  key  Untitled Folder  WS
siddhartha@siddhartha-Inspiron-545s ~/Desktop $ cd Untitled\ Folder/
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ ls
film_review
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git@github.com:siddhartha-ramesh/FilmReview.git
fatal: remote origin already exists.
siddhartha@siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
To git@github.com:siddhartha-ramesh/FilmReview.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:siddhartha-ramesh/FilmReview.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

如果您在本地repo(github repo的克隆版)中有包含文件(本例中为图片)的文件夹,则要在github上查看该文件夹,只需执行以下操作:

cd /path/to/that/folder
git add .
git commit "add folder with pictures"
git push
# or, if this is your first push:
git push -u origin master
换句话说,您可以添加该文件夹中的所有文件,并将其推送

与其尝试添加远程,不如先克隆GitHub repo,在本地克隆和推送中添加内容。
不要先使用ssh,使用基于https的更简单url和您的登录/密码:

git clone https://siddhartha-ramesh@github.com/siddhartha-ramesh/FilmReview
cd FilmReview
git config user.name siddhartha-ramesh
git config user.email (your email address used on GitHub)
# add your files
git add .
git commit -m "Add folder"
git push -u origin master
# the next push can be simply 'git push'

GitHub在这方面的UI在这些年来一直没有改变。如果要通过GitHub UI添加目录,必须执行以下操作:

  • 选择添加文件
  • 不要像你想的那样选择上传文件。相反,选择“创建新文件”
  • 在顶部显示您的项目名称的地方,您应该看到“命名您的文件…”。键入要添加的目录名,而不是键入名称,并键入“/”而不是按enter键
  • 现在,您需要将一个真实的文件添加到该目录中,或者只创建一个包含虚假内容的虚假文件名。在我的例子中,我在第1行用“test”给它命名为“test.js”
  • 现在,您需要提交该文件
  • GitHub将创建一个目录并上载您的新文件
  • 现在,如果需要,可以删除测试文件,新目录将保留

  • 警告:我不确定是否可以使用“/”技巧创建两层深的嵌套目录。

    您的意思是将其添加到项目中吗?图像文件没有什么神奇之处。别忘了添加目录,而不仅仅是其中的文件。你能告诉我们上传过程是否返回一些错误吗?值得注意的是,图像通常是一个相当大的文件,因此需要一些时间来完成上传。我真的面临很多麻烦,我也做了同样的事情,但什么都没有得到uploaded@SwaroopNagendra没问题,我已经用逐步解决方案编辑了我的答案。