首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git add -均为Git 2.3.5

git add -均为Git 2.3.5
EN

Stack Overflow用户
提问于 2016-07-09 19:06:40
回答 1查看 553关注 0票数 1

我想把一个现有的项目上传给Github。

我使用Git 2.3.5是因为较新的版本不兼容Mac (10.7.5)。

我尝试使用git add eu,因为我在指南中找到了。结果是以下错误:

代码语言:javascript
复制
fatal: pathspec 'eu' did not match any files

我也尝试过git add .git add --all。它给了我一条完全空白的新行。

那么,我将如何将我现有的Maven项目上传到Github呢?

  • Mac v10.7.5
  • Git V2.3.5

新错误:

代码语言:javascript
复制
MBA-10-09:~ myname$ git push -u origin master
To https://github.com/myname/importer.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/myname/importer.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
代码语言:javascript
复制
MBA-10-09:~ myname$ git config --global pull.rebase true
MBA-10-09:~ myname$ git stash
Saved working directory and index state WIP on master: b1c9c72 Added Importer v0.1-Beta
HEAD is now at b1c9c72 Added Importer v0.1-Beta
MBA-10-09:~ myname$ git pull --rebase
warning: no common commits
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
From https://github.com/bys1/importer
 * [new branch]      master     -> origin/master
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

MBA-10-09:~ myname$ git stash pop
Removing README.md
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    deleted:    README.md

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .CFUserTextEncoding
    .bash_history
    .cache/
    .config/
    .cups/
    .dropbox/
    .eclipse/
    .gitconfig
    .gmwoommrc
    .local/
    .m2/
    .mediafire/
    .oracle_jre_usage/
    .p2/
    .sh_history
    .ssh/
    .tkyczxzn
    Applications/
    BuildData/
    BuildTools.log.txt
    Bukkit/
    CraftBukkit/
    Desktop/
    Documents/
    Downloads/
    Dropbox/
    Library/
    Movies/
    Music/
    Pictures/
    Public/
    Spigot/
    apache-maven-3.2.5/
    craftbukkit-1.10.jar
    magic.mgc
    spigot-1.10.jar
    work/


It took 2.42 seconds to enumerate untracked files. 'status -uno'
may speed it up, but you have to be careful not to forget to add
new files yourself (see 'git help status').
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (3eb015298d6369d65ba7551f0f81178b63cc119e)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-10 05:38:33

文章的确提到:

在命令/终端上,导航到您先前克隆的本地GitHub存储库

这意味着您必须先克隆GitHub回购(在此之前先克隆:在GitHub上创建回购)。

代码语言:javascript
复制
cd c:\users\mylogin
git clone https://github.com/<myaccount>/<my-test-repo>.git

在c:\user\mylogin\中,您将看到一个.git文件夹。

在相同的回购中,您可以添加文件,然后:

代码语言:javascript
复制
git add "name of generated folder" (in my case git add org) then enter
git commit -m "Sensible commit message"
git push -u origin master

如果您的git是最近的(2.5+,取2.9),输入(仅一次)

代码语言:javascript
复制
 git config --global rebase.autosquash true
 git config --global pull.rebase true

这样,当您在git push上出现"Updates were rejected because the remote contains work that you do not have locally“这样的错误时,您所需要做的就是:

代码语言:javascript
复制
git pull

您的本地分支将重新基于其更新的远程跟踪分支(origin/xxx)的顶部。

如果您的工作正在进行中(没有跟踪,或者只是添加到索引中),它将被存储起来,以便允许重基发生,然后弹回您的工作树。

使用GIT2.3.5,git config --global pull.rebase true就可以工作了。

这让你有:

代码语言:javascript
复制
git stash
git pull --rebase
git stash pop
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38285362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档