我想把一个现有的项目上传给Github。
我使用Git 2.3.5是因为较新的版本不兼容Mac (10.7.5)。
我尝试使用git add eu,因为我在指南中找到了。结果是以下错误:
fatal: pathspec 'eu' did not match any files我也尝试过git add .和git add --all。它给了我一条完全空白的新行。
那么,我将如何将我现有的Maven项目上传到Github呢?
新错误:
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.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)发布于 2016-07-10 05:38:33
文章的确提到:
在命令/终端上,导航到您先前克隆的本地GitHub存储库
这意味着您必须先克隆GitHub回购(在此之前先克隆:在GitHub上创建回购)。
cd c:\users\mylogin
git clone https://github.com/<myaccount>/<my-test-repo>.git在c:\user\mylogin\中,您将看到一个.git文件夹。
在相同的回购中,您可以添加文件,然后:
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),输入(仅一次)
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“这样的错误时,您所需要做的就是:
git pull您的本地分支将重新基于其更新的远程跟踪分支(origin/xxx)的顶部。
如果您的工作正在进行中(没有跟踪,或者只是添加到索引中),它将被存储起来,以便允许重基发生,然后弹回您的工作树。
使用GIT2.3.5,git config --global pull.rebase true就可以工作了。
这让你有:
git stash
git pull --rebase
git stash pophttps://stackoverflow.com/questions/38285362
复制相似问题