여러 파일을 한 폴더에 보관합니다. 이 폴더는 구성 폴더이며 Git 지원 Stow 백업에서 원하지 않는 기타 임시 또는 시스템별 파일이 포함되어 있습니다.
Stow의 git 저장소에 의도적인 파일만 커밋하는 가장 좋은 방법은 무엇입니까? 다소 미사용인가요 git commit -a
?
인사
답변1
*
파일에만 줄을 추가하십시오 .gitignore
. git add
파일이나 디렉토리는 이 옵션을 사용하여 강제로 추가하는 경우에만 추가됩니다 -f
.
예를 들어:
$ mkdir /tmp/git-test
$ cd /tmp/git-test
$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /tmp/git-test/.git/
$ date > file1.txt
$ date > file2.txt
$ date > file3.txt
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
file1.txt
file2.txt
file3.txt
nothing added to commit but untracked files present (use "git add" to track)
$ echo '*' > .gitignore
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
$ git add file1.txt
The following paths are ignored by one of your .gitignore files:
file1.txt
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
$ git add -f file1.txt
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file1.txt
$ git commit -m 'initial commit'
[master (root-commit) 2007ca3] initial commit
1 file changed, 1 insertion(+)
create mode 100644 file1.txt
$ date >> file1.txt
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: file1.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git commit -m '2nd commit' .
[master dba5fea] 2nd commit
1 file changed, 1 insertion(+)
$ git commit -m '3rd commit' *
error: pathspec 'file2.txt' did not match any file(s) known to git
error: pathspec 'file3.txt' did not match any file(s) known to git
$ date >> file1.txt
$ git commit -a -m '3rd commit'
[master e679fde] 3rd commit
1 file changed, 1 insertion(+)
$ mkdir foo
$ date >> foo/bar.txt
$ git status
On branch master
nothing to commit, working tree clean
$ git add -f foo
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: foo/bar.txt
$ git commit -a -m '4th commit'
[master 4048a90] 4th commit
1 file changed, 1 insertion(+)
create mode 100644 foo/bar.txt