Github에 특정 파일이 올라가지 않을 때 (gitignore_global)

LeeKyoungChang·2023년 10월 24일
0
post-thumbnail

현재 문제 상황

Spring initializr에서 Spring 프로젝트를 다운 받은 후, 압축을 풀어서 실행
이후, Github Repository에 올리기 위해 git init 명령어를 입력하여 git을 프로젝트 디렉터리 안에 추가했습니다.

하지만 git add . 를 했을 때 build.gradle, gradlew 등 특정 파일들이 git에 올라가지 않은 문제 상황이 발생했습니다.

스크린샷 2023-10-24 오전 10 53 59

 

✔️ 문제 추적

git init 을 하면 .gitignore 파일이 생성되는데 이것 때문에 build.gradle, gradlew 파일이 추가되지 않는걸까?

HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

찾아봤지만, 편집기에는 해당 파일 이름 관련 된 것이 입력되어 있지 않았다.

무엇일까? 라는 생각에 여러가지 테스트 하며 구글링 하던 중, 유튜브에서 gitignore은 global에서도 사용할 수 있다. 라는 영상을 보게 되었다.

유튜브 영상

 

 

gitignore_global 해결 방안

모든 리포지토리에 대해 전역적으로 .gitignore를 설정하는 방법이 있는데, 그것은 gitignore_global 파일에서 해당 파일 이름을 추가해주면 된다.

 

✔️ 현재 나의 상황

스크린샷 2023-10-24 오전 11 08 25

Spring Boot 파일들이 gitignore_global에 추가되어 있어, git add . 할 때 해당 파일들이 Git에 추가되지 않는 문제 상황이 발생했다.

 

10dd

입력되어 있는 모든 명령어를 지운 후,

gitignore.io 사이트 방문해서 공통적으로 사용될만한 Java, Intellij, macos 명령어들을 gitignore_global에 추가했다.

gitignore.io

# Created by https://www.toptal.com/developers/gitignore/api/java,macos,intellij
# Edit at https://www.toptal.com/developers/gitignore?templates=java,macos,intellij

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn.  Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

# End of https://www.toptal.com/developers/gitignore/api/java,macos,intellij
스크린샷 2023-10-24 오전 11 56 51

 

✔️ git add . 와 push 했을 때 repository 결과는?

스크린샷 2023-10-24 오전 11 58 47

성공적으로 파일들이 Repository에 추가된 것을 확인할 수 있다.

 

 


참고

profile
"야, (오류 만났어?) 너두 (해결) 할 수 있어"

0개의 댓글