如何在git中使用gitignore命令 [英] How to use gitignore command in git

查看:58
本文介绍了如何在git中使用gitignore命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次使用git.我将我的分支推送到github上,并将所有库和文档推送到github中.现在我该怎么办,我该如何使用gitignore命令再次避免相同的错误.

I'm working first time on git. I have pushed my branch on github and it pushed all the library and documents into the github. Now what can I do and how can I use gitignore command to avoid the same mistake again.

推荐答案

因此,根据您所说的,这些文件是您不想删除但也不希望推送到github的库/文档.假设您的项目位于文件夹your_project和一个doc目录:your_project/doc.

So based on what you said, these files are libraries/documentation you don't want to delete but also don't want to push to github. Let say you have your project in folder your_project and a doc directory: your_project/doc.

  1. 从项目目录中删除它(实际上并没有删除它): git rm --cached doc/*
  2. 如果您还没有.gitignore,则可以在项目文件夹中创建一个:project/.gitignore.
  3. doc/*放入.gitignore
  4. 暂存要提交的文件:git add project/.gitignore
  5. 提交:git commit -m "message".
  6. 将更改推送到github.
  1. Remove it from the project directory (without actually deleting it): git rm --cached doc/*
  2. If you don't already have a .gitignore, you can make one right inside of your project folder: project/.gitignore.
  3. Put doc/* in the .gitignore
  4. Stage the file to commit: git add project/.gitignore
  5. Commit: git commit -m "message".
  6. Push your change to github.

这篇关于如何在git中使用gitignore命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆