我刚刚参加git,我试图研究这个有用的cvs。
但我将一些项目推送到远程存储库,我想更新状态并推送此更改。
在此之前,我想添加所有已完成的更改。
但是当我跑git add .
时 - 它什么都不做。
状态与我运行此命令之前的状态相同。
以下是更多信息:
nazar_art@nazar-desktop:~/workspace/NewYearGift$ git st
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .classpath
# new file: .project
# new file: .settings/org.eclipse.core.resources.prefs
# new file: .settings/org.eclipse.jdt.core.prefs
# new file: .settings/org.eclipse.m2e.core.prefs
# new file: README.md
# new file: logs/new-year-gift.log
# new file: output/GiftList_1387287018363.xml
# new file: pom.xml
# new file: src/main/java/com/epam/lab/controller/GiftController.java
# new file: src/main/java/com/epam/lab/model/ItemGiftBuilder.java
# new file: src/main/java/com/epam/lab/model/ItemGiftParser.java
# new file: src/main/java/com/epam/lab/model/NewYearGift.java
# new file: src/main/java/com/epam/lab/model/sweets/Caramel.java
# new file: src/main/java/com/epam/lab/model/sweets/Chewy.java
# new file: src/main/java/com/epam/lab/model/sweets/DarkChocolate.java
# new file: src/main/java/com/epam/lab/model/sweets/DesertChocolate.java
# new file: src/main/java/com/epam/lab/model/sweets/Generator.java
# new file: src/main/java/com/epam/lab/model/sweets/Halva.java
# new file: src/main/java/com/epam/lab/model/sweets/MilkChokolate.java
# new file: src/main/java/com/epam/lab/model/sweets/PorousChocolate.java
# new file: src/main/java/com/epam/lab/model/sweets/Sweets.java
# new file: src/main/java/com/epam/lab/model/sweets/SweetsGenerator.java
# new file: src/main/java/com/epam/lab/model/sweets/Waffles.java
# new file: src/main/java/com/epam/lab/model/sweets/WhiteChocolate.java
# new file: src/main/java/com/epam/lab/view/Application.java
# new file: src/main/java/com/epam/lab/view/Main.java
# new file: src/main/resources/log4j.properties
#
nazar_art@nazar-desktop:~/workspace/NewYearGift$ git add .
nazar_art@nazar-desktop:~/workspace/NewYearGift$ git st
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: .classpath
# new file: .project
# new file: .settings/org.eclipse.core.resources.prefs
// the same thing
我无法弄清楚为什么会这样?
它应该添加所有更改,但它会忽略所有更改...
有什么建议吗?
答案 0 :(得分:2)
您的git add .
按预期工作 - 它记录了您将目标文件添加到索引中的意图。但是,为了完成添加,您需要提交:使用命令git commit
,它将创建提交对象,您将能够使用git push
实际推送您的更改。
注意:您可能不想添加logs/new-year-gift.log
或.settings/org.eclipse.core.resources.prefs
等文件。我建议您使用git reset
将其从列表中删除,如下所示:
git reset logs/ .settings/
并且可能使用以下内容创建.gitignore
:
.settings/
*.log
答案 1 :(得分:0)
您实际上已经添加了文件。 Git有一个临时区域(也称为“索引”)的概念,它是在提交之前放置文件的地方。因此,典型的工作流程是:
git add
将文件添加到索引中。git commit
以实际将索引中暂存的更改提交到存储库中。当您希望有选择地逐项添加内容时,这非常有用。