我在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