java - 将 Git 文件替换为新文件

标签 java eclipse git github

我已经从现有的 Git 存储库创建了一个 Eclipse 项目。

它包含一些示例文档和代码,但我发现删除它们并从头开始更容易。

下次提交和推送时,存储库中的旧文档是否会毫无问题地删除?

最佳答案

请按照以下步骤操作:

NOTE : origin here refers to your remote project location.

第 1 步:从命令行导航到您工作的项目目录

第 2 步:在命令行中运行以下命令

   git pull origin master /* Just to make sure you will get all the latest files from remote repository where you have hosted your project */

   git rm * /* To remove all the files from you current directory */
       OR
   git rm file1.txt file2.txt /* to remote specific files */

   git add . /* Add the deleted files for staging */

   git commit -m "Removed obsolate files" /* Commit the deleted files into your local repository */

   git push origin master /* Now push to the remote repository all the changes that you have done, all the deleted files will be now removed from remote repository */

第 3 步:现在您可以开始使用新文件

关于java - 将 Git 文件替换为新文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48804711/

相关文章:

java - 按钮设置为左对齐,但仍显示为居中

java - Aptana Studio 与 Eclipse

Git,Github - origin/main 与 origin/master

git - 在 Visual Studio 2015 中将 WinMerge 设置为差异/merge 工具

java - 无法使用 Java BufferedReader 读取文件 : Stream closed

java - Java 中的 Makefile 创建

java - 在 Play 框架中发送有关服务器错误的电子邮件

java - Google App Engine servlet 使用 Eclipse 插件抛出 java.security.AccessControlException

java - 将文件从文件系统复制到项目并正确管理进度监视器

git - git filter-branch 遇到问题, "ambiguous argument"