2

I am building a kernel for android and I already setup git so it ignores all generated .o files. I made my first commit before the build (changing some selinux stuff) and that went fine.

I built my kernel and when I tried to run another commit, it listed thousands of .c and .h files that were changed during build which I don't really want to commit since it's unnecessary, I obviously cannot exclude these files because if I modify these later I can't commit them.

Any ideas on how to ignore all files that were modified during the build?

royki
  • 1,593
  • 3
  • 25
  • 45
user265889
  • 667
  • 1
  • 10
  • 24

3 Answers3

4

git update-index --assume-unchanged file

From documentation of git update-index:

When this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index

To undo & start tracking again,
git update-index --no-assume-unchanged file

Rishit Sanmukhani
  • 2,159
  • 16
  • 26
  • Really nice, but when a change comes from another user, will Git overwrite the file and my changes (assuming I have changed the file manually) or try to merge? – user2173353 Jul 22 '19 at 07:01
1

The way I'd go about it is with a nice, simple git checkout -- . in your project's root dir. What that'll do is reset all tracked files to their state at the HEAD commit.

Sebastian Lenartowicz
  • 4,695
  • 4
  • 28
  • 39
0

maybe write the file pattern you want to ignore ini .git/info/exclude ?

ref Few questions with GIT, possible to have custom .gitignore? Read only access?

in this way you would not have to append ignore rules in .gitignore and also ignore the files you want to ignore.

for further information, you can take a look at ignore rules generated by gitignore.io: https://www.gitignore.io/api/android . attached below:

# Created by https://www.gitignore.io/api/android

### Android ###
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/libraries

# Keystore files
*.jks

### Android Patch ###
gen-external-apklibs
Community
  • 1
  • 1
Ya Zhuang
  • 4,652
  • 31
  • 40