git 如何git提交整个文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18248177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to git commit a whole folder?
提问by Miyazaki
Here is a folder, which contains a lot of .java files.
这是一个文件夹,其中包含很多 .java 文件。
How can I git commit this folder ?
我怎样才能 git commit 这个文件夹?
If I do the following commands
如果我执行以下命令
git add foldername
git commit foldername -m "commit operation"
I will see the messages nothing added to commit but untracked fils present (use "git add" to track)
我会看到消息没有添加到提交但存在未跟踪的文件(使用“git add”来跟踪)
回答by devrobf
You don't "commit the folder" - you add the folder, as you have done, and then simply commit all changes. The command should be:
您没有“提交文件夹” - 您添加了文件夹,就像您所做的那样,然后简单地提交所有更改。命令应该是:
git add foldername
git commit -m "commit operation"
回答by Sweet Chilly Philly
To Add a little to the above answers:
在上面的答案中添加一点:
If you are wanting to commit a folder like the above
如果你想提交一个像上面这样的文件夹
git add foldername
git commit -m "commit operation"
To add the folder you will need to be on the same level as, or above, the folder you are trying to add.
要添加文件夹,您需要与您尝试添加的文件夹处于同一级别或更高级别。
For example: App/Storage/Emails/email.php
例如:App/Storage/Emails/email.php
If you are trying to add the "Storage" file but you have been working inside it on the email.php document you will not be able to add the "Storage" file unless you have 'changed directory' (cd ../) back up to the same level, or higher, as the Storage file itself
如果您尝试添加“存储”文件,但您一直在处理 email.php 文档中的“存储”文件,您将无法添加“存储”文件,除非您已“更改目录”(cd ../)回来与存储文件本身的级别相同或更高
回答by Martin Bean
When you “add” something in Git, you add it to the staging area. When you commit, you then commit what's in the staging area, meaning it's possible to commit only a sub-set of changed files at any one time.
当你在 Git 中“添加”一些东西时,你将它添加到暂存区。当您提交时,您将提交暂存区中的内容,这意味着在任何时候都可以只提交更改文件的子集。
In your case, you want to add the folder to the staging area, and then just do a normal commit:
在您的情况下,您想将该文件夹添加到暂存区,然后执行正常提交:
$ git add foldername
$ git commit -m 'Helpful commit message'
回答by RavenReema
OR, even better just the ol' "drag and drop" the folder, onto your repository opened in git browser.
或者,更好的是将 ol“拖放”文件夹到在 git 浏览器中打开的存储库中。
Open your repository in the web portal , you will see the listing of all your files. If you have just recently created the repo, and initiated with a README, you will only see the README listing.
Open your folder which you want to upload. drag and drop on the listing in browser. See the image here.
在门户网站中打开您的存储库,您将看到所有文件的列表。如果您最近刚刚创建了 repo,并使用 README 启动,您将只会看到 README 列表。
打开您要上传的文件夹。拖放浏览器中的列表。请参阅此处的图像。
回答by kholid.nur
To stage an entire folder, you'd enter this command:
要暂存整个文件夹,您需要输入以下命令:
$git add .
The period will add all files in the folder.
句号将添加文件夹中的所有文件。
回答by DevGalT
I ran into the same problem. Placing a forward slash after the folder name worked for me.
我遇到了同样的问题。在文件夹名称后放置一个正斜杠对我有用。
ex: git add foldername/
例如:git add 文件夹名/