what will happen if I add a file to my git repo and later add a pattern in gitignore that suggests that file is to be ignored

Suppose I have an android project in my repo and I add the apk file. Later I add a gitignore let’s say this one. What will happen in the future to this apk file? The file will keep on changing after each build so will it be checked by git or not? In my case, I want it to continue tracking this file.

  • Unignore specific Files in Subdirectory with .gitignore
  • How do I open source my Rails' apps without giving away the app's secret keys and credentials
  • TortoiseGit: add to ignore already commited gen and bin folder
  • Git Ignore strangeness
  • git update-index --assume-unchanged not working as expected when merging
  • What should be in my .gitignore for an Android Studio project?
  • How to commit Composer vendor folder into Git repository?
  • Git - Multiple branches with different file systems
  • One Solution collect form web for “what will happen if I add a file to my git repo and later add a pattern in gitignore that suggests that file is to be ignored”

    The file will continue to be tracked. You can easily find this out just by trying:

    $ mkdir /tmp/test
    $ cd /tmp/test
    $ git init
    $ touch foo
    $ git add foo
    $ echo "foo" > .gitignore
    $ git add .gitignore
    $ git commit -m "initial commit"
    $ echo foo > foo
    

    Now, git status will show modified: foo and if you git add foo, it will be staged despite the .gitignore.

    Git Baby is a git and github fan, let's start git clone.