我在Mac OS上。我打开终端,进入文件夹~/../../Search_Engine
,其中包含一堆已经推送到我的GitHub的Java文件,以及该项目以前版本的文件夹(在Project 1
,Project 2
等文件夹中)所以我会让你运行我在做什么以及我的问题出现在哪里。git新手 - git add/commit/push/pull
再次,我cd
到~/../../Search_Engine
,这我已经使用git init
上。我试试这个:
nathan-fuller-mbp:Search_Engine nathanfuller$ git add Project\ 2
nathan-fuller-mbp:Search_Engine nathanfuller$ git commit -m 'project 2 commit'
,然后这个烂摊子发生......
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# AssignmentsInterface.java
# CommandInterface.java
# DatabaseInterface.java
# DocumentInterface.java
# ExpressionTreeInterface.java
# HistoryInterface.java
# InvertedFileInterface.java
# InvertedListInterface.java
# MapInterface.java
# NextCommandInterface.java
# Project 3/
# Project 4/
# Project 5/
# Project 6/
# ResultListInterface.java
# TestHarness.java
# WordListInterface.java
nothing added to commit but untracked files present (use "git add" to track)
nathan-fuller-mbp:Search_Engine nathanfuller$
所以这是我的第一个问题。任何人都可以向我解释发生这种情况时发生了什么,以及为什么它发生在第一位?
继续...我试图把(我可能不应该,因为我们已经达到我们的问题,但我会只显示反正会发生什么):
nathan-fuller-mbp:Search_Engine nathanfuller$ git push origin master
To https://github.com/NateFuller/Search-Engine.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/NateFuller/Search-Engine.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.
nathan-fuller-mbp:Search_Engine nathanfuller$
有什么建议?如果您希望我发布更多详细信息,请告诉我。
man git。 http://try.github.io/levels/1/challenges/1或其他教程。这是非常基本的东西,与编程无关,对不起。 –
issue'git stash','git pull','git stash apply',然后修正所有不一致,并且做:'git add .','git commit','git push origin master' –
@MihaiMaruseac - 我可以推荐你阅读我们的“主题”页面? http://stackoverflow.com/help/on-topic:关于*“程序员常用的软件工具*”的问题,例如git,在这里是主题。谢谢。 – Kev