your programing

Subversion에서 파일을 어떻게 무시합니까?

lovepro 2020. 10. 2. 23:03
반응형

Subversion에서 파일을 어떻게 무시합니까?


Subversion에서 파일을 어떻게 무시합니까?

또한 버전 관리가되지 않는 파일을 어떻게 찾습니까?


(이 답변은 SVN 1.8 및 1.9의 동작과 일치하도록 업데이트되었습니다)

두 가지 질문이 있습니다.

무시 된 파일로 표시 :

"무시 된 파일"이란 파일이 "버전 없음"으로도 목록에 나타나지 않음을 의미합니다. SVN 클라이언트는 파일이 파일 시스템에 전혀 존재하지 않는 것처럼 가장합니다.

무시 된 파일은 "파일 패턴"으로 지정됩니다. 파일 패턴의 구문과 형식은 SVN의 온라인 설명서에 설명되어 있습니다. http://svnbook.red-bean.com/nightly/en/svn.advanced.props.special.ignore.html "Subversion의 파일 패턴".

버전 1.8 (2013 년 6 월) 이후 Subversion은 파일 패턴을 지정하는 3 가지 방법을 지원합니다. 다음은 예를 요약 한 것입니다.

1-런타임 구성 영역- global-ignores옵션 :

  • 이것은 클라이언트 측 전용 설정이므로 global-ignores다른 사용자가 목록을 공유하지 않으며 컴퓨터에서 체크 아웃 한 모든 저장소에 적용됩니다.
  • 이 설정은 런타임 구성 영역 파일에 정의됩니다.
    • Windows (파일 기반)- C:\Users\{you}\AppData\Roaming\Subversion\config
    • 윈도우 (레지스트리 기반) - Software\Tigris.org\Subversion\Config\Miscellany\global-ignores모두 HKLMHKCU.
    • Linux / Unix- ~/.subversion/config

2- svn:ignore디렉토리 (파일이 아님)에 설정되는 특성 :

  • 이것은 저장소 내에 저장되므로 다른 사용자는 동일한 무시 파일을 갖게됩니다. .gitignore작동 방식과 유사 합니다.
  • svn:ignore디렉토리에 적용되며 비 재귀 적이거나 상속됩니다. 파일 패턴과 일치하는 상위 디렉토리의 모든 파일 또는 바로 아래 하위 디렉토리는 제외됩니다.
  • SVN 1.8은 "상속 된 속성"이라는 개념을 추가하지만 svn:ignore속성 자체는 직계가 아닌 하위 디렉터리에서 무시됩니다.

    cd ~/myRepoRoot                             # Open an existing repo.
    echo "foo" > "ignoreThis.txt"                # Create a file called "ignoreThis.txt".
    
    svn status                                  # Check to see if the file is ignored or not.
    > ?    ./ignoreThis.txt
    > 1 unversioned file                        # ...it is NOT currently ignored.
    
    svn propset svn:ignore "ignoreThis.txt" .   # Apply the svn:ignore property to the "myRepoRoot" directory.
    svn status
    > 0 unversioned files                       # ...but now the file is ignored!
    
    cd subdirectory                             # now open a subdirectory.
    echo "foo" > "ignoreThis.txt"                # create another file named "ignoreThis.txt".
    
    svn status
    > ?    ./subdirectory/ignoreThis.txt        # ...and is is NOT ignored!
    > 1 unversioned file
    

    (따라서 ./subdirectory/ignoreThis" ignoreThis.txt"이 .저장소 루트 에 적용 되더라도 파일 은 무시되지 않습니다 .)

  • 따라서 무시 목록을 재귀 적으로 적용하려면을 사용해야합니다 svn propset svn:ignore <filePattern> . --recursive.

    • 이렇게하면 모든 하위 디렉터리에 속성 복사본이 만들어집니다.
    • <filePattern>하위 디렉토리에서 값이 다른 경우 하위 값이 상위를 완전히 덮어 쓰므로 "추가"효과가 없습니다.
    • 따라서 <filePattern>루트 .에서를 변경하는 --recursive경우 하위 및 하위 디렉터리에 덮어 쓰도록로 변경해야합니다 .
  • 명령 줄 구문은 직관적이지 않습니다.

    • 나는 svn ignore pathToFileToIgnore.txtSVN의 무시 기능이 작동하는 방식이 아니지만 다음과 같이 입력하여 SVN의 파일을 무시한다고 가정하기 시작했습니다 .

3- svn:global-ignores재산. SVN 1.8 필요 (2013 년 6 월) :

  • 이것은 svn:ignoreSVN 1.8의 "상속 된 속성"기능을 사용한다는 점을 제외하면 과 유사 합니다.
  • 에 비해 svn:ignore파일 패턴은 모든 하위 디렉터리 (직계 하위 디렉터리가 아님)에 자동으로 적용됩니다.
    • 설정 불필요이 수단 svn:global-ignores--recursive상속으로, 플래그은 상속하고 같은 파일 패턴이 자동으로 적용됩니다 무시합니다.
  • 이전 예제에서와 동일한 명령 세트를 실행하지만 svn:global-ignores대신 다음을 사용 합니다.

    cd ~/myRepoRoot                                    # Open an existing repo
    echo "foo" > "ignoreThis.txt"                       # Create a file called "ignoreThis.txt"
    svn status                                         # Check to see if the file is ignored or not
    > ?    ./ignoreThis.txt
    > 1 unversioned file                               # ...it is NOT currently ignored
    
    svn propset svn:global-ignores "ignoreThis.txt" .
    svn status
    > 0 unversioned files                              # ...but now the file is ignored!
    
    cd subdirectory                                    # now open a subdirectory
    echo "foo" > "ignoreThis.txt"                       # create another file named "ignoreThis.txt"
    svn status
    > 0 unversioned files                              # the file is ignored here too!
    

TortoiseSVN 사용자의 경우 :

This whole arrangement was confusing for me, because TortoiseSVN's terminology (as used in their Windows Explorer menu system) was initially misleading to me - I was unsure what the significance of the Ignore menu's "Add recursively", "Add *" and "Add " options. I hope this post explains how the Ignore feature ties-in to the SVN Properties feature. That said, I suggest using the command-line to set ignored files so you get a feel for how it works instead of using the GUI, and only using the GUI to manipulate properties after you're comfortable with the command-line.

Listing files that are ignored:

The command svn status will hide ignored files (that is, files that match an RGA global-ignores pattern, or match an immediate parent directory's svn:ignore pattern or match any ancesor directory's svn:global-ignores pattern.

Use the --no-ignore option to see those files listed. Ignored files have a status of I, then pipe the output to grep to only show lines starting with "I".

The command is:

svn status --no-ignore | grep "^I"

For example:

svn status
> ? foo                             # An unversioned file
> M modifiedFile.txt                # A versioned file that has been modified

svn status --no-ignore
> ? foo                             # An unversioned file
> I ignoreThis.txt                  # A file matching an svn:ignore pattern
> M modifiedFile.txt                # A versioned file that has been modified

svn status --no-ignore | grep "^I"
> I ignoreThis.txt                  # A file matching an svn:ignore pattern

ta-da!


Use the following command to create a list not under version control files.

svn status | grep "^\?" | awk "{print \$2}" > ignoring.txt

Then edit the file to leave just the files you want actually to ignore. Then use this one to ignore the files listed in the file:

svn propset svn:ignore -F ignoring.txt .

Note the dot at the end of the line. It tells SVN that the property is being set on the current directory.

Delete the file:

rm ignoring.txt

Finally commit,

svn ci --message "ignoring some files"

You can then check which files are ignored via:

svn proplist -v

If you are using TortoiseSVN, right-click on a file and then select TortoiseSVN / Add to ignore list. This will add the file/wildcard to the svn:ignore property.

svn:ignore will be checked when you are checking in files, and matching files will be ignored. I have the following ignore list for a Visual Studio .NET project:

bin obj
*.exe
*.dll
_ReSharper
*.pdb
*.suo

You can find this list in the context menu at TortoiseSVN / Properties.


.gitignore like approach

You can ignore a file or directory like .gitignore. Just create a text file of list of directories/files you want to ignore and run the code below:

svn propset svn:ignore -F ignorelist.txt .

OR if you don't want to use a text file, you can do it like this:

svn propset svn:ignore "first
 second
 third" .

Source: Karsten's Blog - Set svn:ignore for multiple files from command line


I found the article .svnignore Example for Java.

Example: .svnignore for Ruby on Rails,

/log

/public/*.JPEG
/public/*.jpeg
/public/*.png
/public/*.gif

*.*~

And after that:

svn propset svn:ignore -F .svnignore .

Examples for .gitignore. You can use for your .svnignore

https://github.com/github/gitignore


As nobody seems to have mentioned it...

svn propedit svn:ignore .

Then edit the contents of the file to specify the patterns to ignore, exit the editor and you're all done.


When using propedit make sure not have any trailing spaces as that will cause the file to be excluded from the ignore list.

These are inserted automatically if you've use tab-autocomplete on linux to create the file to begin with:

svn propset svn:ignore 'file1
file2' .

Another solution is:

svn st | awk '/^?/{print $2}' > svnignore.txt && svn propget svn:ignore >> svnignore.txt && svn propset svn:ignore -F svnignore.txt . && rm svnignore.txt

or line by line

svn st | awk '/^?/{print $2}' > svnignore.txt 
svn propget svn:ignore >> svnignore.txt 
svn propset svn:ignore -F svnignore.txt . 
rm svnignore.txt

What it does:

  1. Gets the status files from the svn
  2. Saves all files with ? to the file "svnignore.txt"
  3. Gets the already ignored files and appends them to the file "svnignore.txt"
  4. Tells the svn to ignore the files in "svnignore.txt"
  5. Removes the file

Also, if you use Tortoise SVN you can do this:

  1. In context menu select "TortoiseSVN", then "Properties"
  2. In appeared window click "New", then "Advanced"
  3. In appeared window opposite to "Property name" select or type "svn:ignore", opposite to "Property value" type desired file name or folder name or file mask (in my case it was "*/target"), click "Apply property recursively"
  4. Ok. Ok.
  5. Commit

A more readable version of bkbilly's answer:

svn st | awk '/^?/{print $2}' > svnignore.txt
svn propget svn:ignore >> svnignore.txt
svn propset svn:ignore -F svnignore.txt .
rm svnignore.txt

What it does:

  1. Gets the status files from the svn
  2. Saves all files with ? to the file "svnignore.txt"
  3. Gets the already ignored files and appends them to the file "svnignore.txt"
  4. Tells the svn to ignore the files in "svnignore.txt"
  5. Removes the file

  1. cd ~/.subversion
  2. open config
  3. find the line like 'global-ignores'
  4. set ignore file type like this: global-ignores = *.o *.lo *.la *.al .libs *.so .so.[0-9] *.pyc *.pyo 88 *.rej ~ ## .#* .*.swp .DS_Store node_modules output

You can also set a global ignore pattern in SVN's configuration file.


svn status will tell you which files are not in SVN, as well as what's changed.

Look at the SVN properties for the ignore property.

For all things SVN, the Red Book is required reading.


Adding a directory to subversion, and ignoring the directory contents

svn propset svn:ignore '\*.*' .

or

svn propset svn:ignore '*' .

Use the command svn status on your working copy to show the status of files, files that are not yet under version control (and not ignored) will have a question mark next to them.

As for ignoring files you need to edit the svn:ignore property, read the chapter Ignoring Unversioned Items in the svnbook at http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.ignore.html. The book also describes more about using svn status.


SVN ignore is easy to manage in TortoiseSVN. Open TortoiseSVN and right-click on file menu then select Add to ignore list.

This will add the files in the svn:ignore property. When we checking in the files then those file which is matched with svn:ignore that will be ignored and will not commit.

In Visual Studio project we have added following files to ignore:

bin obj
*.exe
*.dll
*.pdb
*.suo

We are managing source code on SVN of Comparetrap using this method successfully


  1. open you use JetBrains Product(i.e. Pycharm)
  2. then click the 'commit' button on the top toolbar or use shortcut 'ctrl + k' screenshot_toolbar
  3. on the commit interface, move your unwanted files to another change list as follows. screenshot_commit_change
  4. next time you can only commit default change list.

What worked for me:

How do I ignore files in Subversion?
1.In File Explorer, right-click on SVN project folder-name
2.Click on "SVN Commit..."
3.A "commit" window will appear
4.Right-click on the folder/file that you want to ignore
5.Click on Add to ignore list
6.Select the folder/file
7.Commit the "property change" to SVN

Also, how do I find files which are not under version control?
After Step 3 above, click on "Show unversioned files"

참고URL : https://stackoverflow.com/questions/86049/how-do-i-ignore-files-in-subversion

반응형