Create a. gitignore file under Windows (some files are ignored when Git commits)

Source: Internet
Author: User

I believe that when you submit a file using the Eclipse git plugin, Will encounter a problem: it is possible to accidentally put unnecessary files are also submitted (such as. project,.classpath file or. Settings folder and the following files, etc.), there is no way to ignore these files?
The simple way to do this is to create a new. gitignore file in the project directory, and then declare the folder or file you want to ignore. The trouble is coming because the file is a point start, no file name, no way to create it directly under Windows. We can create a new. gitignore file from Linux by installing git and then right-clicking on "Git Bash here" on the project root.

The detailed steps are as follows:

    1. To install git, first download the latest git for the Windows platform on the GIT website. When the download is complete, click Install, and in the Select
      Components "Step, remember to select Simple context menu (for example). Other by default, click the next step to complete the installation.
    2. Right-click on "Git Bash here" on the project root to enter the command line.
    3. Input vim. Gitignore command, edit content
      . Project
      . classpath
      . settings
      . gitignore
      Press Wq to save the exit and the. gitignore file will be generated. When you use Git for commit, you will not see the excluded files.
. gitignore file filtering has two modes, open mode and conservative mode
    • Open mode is responsible for setting which files and folders to filter
      Settings/means to filter this folder
      *.zip filtering the zip suffix file
      Test.java Filtering the file
    • Conservative mode is responsible for setting which files are not filtered, that is, which files are to be tracked.
      !src/Track This folder
      !*.java Trace Java source files
      ! Test.java Trace the file

Tips: You can use open mode and conservative mode to configure the method. There are a lot of folders and files under a folder, and I just want to keep track of one of those files. You can use open mode to set the entire directory to not track, and then use the conservative mode to set the folder to track the file to be tracked, you can only trace a file.

Create a. gitignore file under Windows (some files are ignored when Git commits)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.