IT박스

SVN : 파일을 "커밋하지 않음"으로 표시하는 방법이 있습니까?

itboxs 2020. 6. 8. 21:15
반응형

SVN : 파일을 "커밋하지 않음"으로 표시하는 방법이 있습니까?


TortoiseSVN을 사용하면 파일을 커밋 할 때 변경 목록으로 이동하여 전체 트리를 커밋 할 때 해당 파일의 변경 사항이 커밋되지 않습니다.

svn 명령 줄 도구를 사용하여 이와 같은 작업을 수행 할 수있는 방법이 있습니까?

편집 :을 사용하는 제안에 감사드립니다 svn:ignore.하지만 내가 찾고있는 것은 아닙니다.

svn:ignoresvn add& 같은 것들에 영향을줍니다 svn import. 무시할 파일 이름 패턴 목록을 제공합니다.

이미 소스 제어를 받고있는 파일이 있지만 나중에 전체 소스 트리를 커밋 할 때 커밋하지 않으려는 파일을 임시로 변경하고 싶습니다. 다른 많은 변경 작업을하고 있으며 트리를 커밋하기 전에 해당 파일을 되돌 리라고 알려주는 메모를 모니터에 붙일 수 있지만 svn이 해당 파일을 자동으로 건너 뛸 수 있다면 좋을 것입니다.


Subversion에는 2016 년 2 월 / 버전 1.9부터 내장 된 "커밋 안 함"/ "커밋 무시"기능이 없습니다. 이 답변은 비 이상적인 명령 줄 해결 방법입니다.

OP 상태에 따라 TortoiseSVN에는 "커밋 무시"라는 변경 목록이 내장되어있어 커밋에서 자동으로 제외됩니다. 커맨드 라인 클라이언트는 이것을 가지고 있지 않으므로, 동일한 행동을하기 위해 여러 변경 목록을 사용해야합니다 (주의 사항) :

  • 당신이하고 싶은 일을위한 것 [일]
  • 무시하고 싶은 것들에 대한 것 [커밋 무시]

TortoiseSVN이 선행되어 있기 때문에 커밋하고 싶지 않은 파일에 대해서는 예제에서 "커밋 무시"를 사용합니다. 내가하는 파일에 "작업"을 사용하지만 원하는 이름을 선택할 수 있습니다.

먼저 모든 파일을 "work"라는 변경 목록에 추가하십시오. 작업 복사본의 루트에서 실행해야합니다.

svn cl work . -R

그러면 작업 복사본의 모든 파일이 "work"라는 변경 목록에 반복적으로 추가됩니다. 새로운 파일이 작업 복사본에 추가 될 때 새 파일을 구체적으로 추가해야합니다. 그렇지 않으면 포함되지 않습니다. 둘째, 다시 실행해야 할 경우 모든 "커밋 무시"파일을 다시 추가해야합니다. 이상적이지 않습니다-다른 사람들이 한 것처럼 파일에서 자신의 '무시'목록을 유지할 수 있습니다.

그런 다음 제외하려는 파일의 경우 :

svn cl ignore-on-commit path\to\file-to-ignore

파일은 하나의 변경 목록에만있을 수 있으므로 이전 "작업"추가 후에이 추가를 실행하면 "작업"변경 목록에서 무시하려는 파일이 제거되고 "커밋시 무시"변경 목록에 저장됩니다.

수정 한 파일을 커밋 할 준비가되면 커밋에 "--cl work"를 추가하면됩니다.

svn commit --cl work -m "message"

내 컴퓨터에서 간단한 예를 보여줍니다.

D:\workspace\trunk>svn cl work . -R
Skipped '.'
Skipped 'src'
Skipped 'src\conf'
A [work] src\conf\db.properties
Skipped 'src\java'
Skipped 'src\java\com'
Skipped 'src\java\com\corp'
Skipped 'src\java\com\corp\sample'
A [work] src\java\com\corp\sample\Main.java
Skipped 'src\java\com\corp\sample\controller'
A [work] src\java\com\corp\sample\controller\Controller.java
Skipped 'src\java\com\corp\sample\model'
A [work] src\java\com\corp\sample\model\Model.java
Skipped 'src\java\com\corp\sample\view'
A [work] src\java\com\corp\sample\view\View.java
Skipped 'src\resource'
A [work] src\resource\icon.ico
Skipped 'src\test'

D:\workspace\trunk>svn cl ignore-on-commit src\conf\db.properties
D [work] src\conf\db.properties
A [ignore-on-commit] src\conf\db.properties

D:\workspace\trunk>svn status

--- Changelist 'work':
        src\java\com\corp\sample\Main.java
        src\java\com\corp\sample\controller\Controller.java
        src\java\com\corp\sample\model\Model.java
M       src\java\com\corp\sample\view\View.java
        src\resource\icon.ico

--- Changelist 'ignore-on-commit':
M       src\conf\db.properties

D:\workspace\trunk>svn commit --cl work -m "fixed refresh issue"
Sending        src\java\com\corp\sample\view\View.java
Transmitting file data .done
Committing transaction...
Committed revision 9.

대안은 단순히 '작업'변경 목록에 커밋하려는 모든 파일을 추가하고 무시 목록을 유지 관리하지는 않지만 많은 작업입니다. 실제로 유일한 단순하고 이상적인 솔루션은 이것이 SVN 자체에서 구현되는 경우입니다. Subversion 이슈 트래커 SVN-2858 에서는 이것에 대한 오래된 이슈 가 향후에 변경 될 경우에 발생합니다.


나는 일관되게도이 상황에서 자신을 발견했습니다 및 변경 목록은 나를 위해 작동하지 않습니다 - 나는 것을 파일에 대한 간단한 목록을 만들고 싶어 하지 않는 커밋이 아닌 내가 그 파일의 거대한 목록을 유지 관리 할 희망을 커밋하기!

나는 리눅스 커맨드 라인에서 일한다. 그래서 나의 해결책은 다음과 같이 스크립트 / usr / bin / svnn (예, 두 개의 'n!')을 만드는 것이다.

#! /bin/bash
DIR=/home/mike/dev/trunk

IGNORE_FILES="\
        foo/pom.xml \
        foo/src/gwt/App.gwt.xml \
        foo/src/main/java/gwt/Common.gwt.xml \
        foo/src/main/resources/context/datasource/local.xml \
        foo/src/main/resources/context/environment/local.xml"

for i in $IGNORE_FILES; do mv $DIR/$i $DIR/"$i"_; done;

svn "$@"

for i in $IGNORE_FILES; do mv $DIR/"$i"_ $DIR/$i; done;

분명히 이것은 내 상황에 맞게 조정되었지만 개발자 설정에 맞게 DIR 및 IGNORE_FILES를 변경하십시오. 다음을 사용하여 스크립트를 실행 파일로 변경하십시오.

sudo chmod +x /usr/bin/svnn

.. 그런 다음 IGNORE_FILES 목록의 파일에 대한 로컬 변경 사항을 확인할 필요없이 "svn"대신 "svnn"을 사용하여 Subversion을 실행하십시오. 이게 도움이 되길 바란다!


저장소에서 파일을 무시하는 방법이 없다고 생각합니다. 우리는 종종 web.config 및 기타 구성 파일을 사용합니다.

완벽하지는 않지만 가장 자주보고 사용하는 솔루션은 .default 파일과 로컬 복사본을 만드는 nant 작업을 갖는 것입니다.

예를 들어, 저장소 web.config.default에는 기본값 이있는 파일 이 있습니다. 그런 다음 모든 web.config.default파일의 이름을 바꾸고 web.config로컬 값으로 사용자 정의 할 수 있는 nant 태스크를 작성하십시오 . 이 작업은 새 작업 복사본을 검색하거나 빌드를 실행할 때 호출해야합니다.

또한 web.config리포지토리에 커밋되지 않도록 만들어진 파일 을 무시해야 합니다.


Check out changelists, which can provide you with an option to filter out files you have changed but do not want to commit. SVN will not automatically skip a file unless you tell it to - and the way you tell it that this file is somehow different to other files is to put it in a changelist.

It does require more work for you, and you can only apply the changelist to your working copy (obviously, imagine the chaos that could ensue if you could apply a 'never update' property to a revision!).


I came to this thread looking for a way to make an "atomic" commit of just some files and instead of ignoring some files on commit I went the other way and only commited the files I wanted:

svn ci filename1 filename2

Maybe, it will help someone.


Guys I just found a solution. Given that TortoiseSVN works the way we want, I tried to install it under Linux - which means, running on Wine. Surprisingly it works! All you have to do is:

  1. Add files you want to skip commit by running: "svn changelist 'ignore-on-commit' ".
  2. Use TortoiseSVN to commit: "~/.wine/drive_c/Program\ Files/TortoiseSVN/bin/TortoiseProc.exe /command:commit /path:'
  3. The files excluded will be unchecked for commit by default, while other modified files will be checked. This is exactly the same as under Windows. Enjoy!

(The reason why need to exclude files by CLI is because the menu entry for doing that was not found, not sure why. Any way, this works great!)


Conflicted files are not allowed to be committed. You can take advantage of this to keep your private changes out of the repository. This works best with a small number of files.

To get a conflict for a-file, your working copy (WC) does not have the up to date a-file from the repository, and that the a-file in your WC has changes that are in the same location as changes in the repository (changes that you didn't update to yet). If you don't want to wait for the conditions above you can create a conflict for a-file like this:
In working copy 1 (WC1), add a line of text to the top of a-file, such as "make a conflict here". Use the necessary syntax so that you don't break the repository. Commit a-file from WC1. In WC2, add a different line of text to the top of a-file, like "i want a conflict". Update from WC2, and now a-file should be in conflict.


I would instead write a helper bash script that runs svn commit on all the files you need to and none of the ones you don't. This way you have much more control.

For example, with one line, you can commit all files with extension .h and .cpp to which you made changes (and which wouldn't cause a conflict):

svn commit -m "" `svn status | grep "^M.*[h|cpp]$" | awk '{print $2}' | tr "\\n" " "`

Change / add extensions to the [h|cpp] part. Add a log message in between the quotes of -m "" if needed.


Some of the proposed ideas can be implemented like this:

On Windows in PowerShell

add all to default list.ps1

dir -Recurse | ? { -not $_.PSIsContainer } | % { svn cl default $_.FullName }

add to ignore list.ps1

 dir file1 ... filN  % { $_.FullName } > ignore-on-commit
 cat .\ignore-on-commit | % { svn cl ignore-on-commit $_ }
 svn add ignore-on-commit

Now, you can alias svn ci --changelist default so that you don't have to specify it each time. The additional benefit is that you can store the ignore-on-commit list (if you want) in the repository.

I do this for some files which are constantly regenerated but rarely actually changed by hand. For instance I add revision number to my config files on specific placeholders so files are changed on each commit, yet manual change is rare.


I got tired of waiting for this to get built into SVN. I was using tortoiseSVN with ignore-on-commit, but that pops up a user dialog box that you can't suppress from the command line, and when I run my build script and go and make a cup of tea, I hate it when I come back to discover it's waiting for user input 10% of the way through.

So here's a windows powershell script that commits only files that aren't in a changelist:

# get list of changed files into targets
[XML]$svnStatus = svn st -q --xml C:\SourceCode\Monad
# select the nodes that aren't in a changelist
$fileList = $svnStatus.SelectNodes('/status/target/entry[wc-status/@item != "unversioned"]') | Foreach-Object {$_.path};
# create a temp file of targets
$fileListPath =  [IO.Path]::GetTempFileName();
$fileList | out-file $fileListPath -Encoding ASCII
# do the commit
svn commit --targets $fileListPath -m "Publish $version" --keep-changelists 
# remove the temp file
Remove-Item $filelistPath

Update of user88044's script.

The idea is to push the files in the do-not-commit changelist and run the evil script.

The script extracts the do-not-commit files from the command : svn status --changelist 'do-not-commit'

#! /bin/bash DIR="$(pwd)"

IGNORE_FILES="$(svn status --changelist 'do-not-commit' | tail -n +3 | grep -oE '[^ ]+$')"

for i in $IGNORE_FILES; do mv $DIR/$i $DIR/"$i"_; done;

svn "$@";

for i in $IGNORE_FILES; do mv $DIR/"$i"_ $DIR/$i; done;

The script is placed in /usr/bin/svnn (sudo chmod +x /usr/bin/svnn)

svnn status, svnn commit, etc...


You can configure the "ignore-on-commit" changelist directly with TortoiseSVN. No need to configure any other changelist including all the others files

1) Click "SVN Commit..." (we will not commit, just a way to find a graphical menu for the changelist) 2) On the list Right click on the file you want to exclude. 3) Menu: move to changelist > ignore-on-commit

The next time you do a SVN Commit... The files will appear unchecked at the end of the list, under the category ignore-on-commit.

Tested with : TortoiseSVN 1.8.7, Build 25475 - 64 Bit , 2014/05/05 20:52:12, Subversion 1.8.9, -release


This is late to the game, but I found the most awesome-est command line command for this problem. Done using bash. Enjoy.

svn status | grep -v excluding | sed 's/^A */"/g; s/$/"/g' | tr '\n' ' ' | xargs svn commit -m "My Message"

Ok, so here's an explanation of the command. Some things will need to be changed based on your use case.

svn status

I get a list of all the files. They'll all start with those status characters (?, !, A, etc). Each is on its own lines

grep -v excluding

I use grep to filter the list. It can either be used normally (to include) or with the -v flag (to exclude). In this case, it's being used to exclude, with a phrase "excluding" being what will be excluded.

sed 's/^. */"/g; s/$/"/g'

Now I remove the status character and whitespace at the beginning of each line, and then quote each line, using sed. Some of my filenames have spaces in them, hence the quoting.

tr '\n' ' '

Using tr, I replace all newlines with spaces. Now my entire list of files to commit is on one line.

xargs svn commit -m "My Message"

Lastly, I use xargs to execute my commit command with the message. It does the commit, and drops my quoted file list as the last argument.

The result is that everything ultimately works the way that I want it to. I still kind of hate svn for forcing me to jump through these goddamn hoops, but I can live with this. I guess.


As I was facing the exact same issue, and my googling kept giving me nothing, I think I found a workaround. Here's what I did, it seems to work for me, but as I'm stuck with an old version of SVN (< 1.5, as it doesn't have the --keep-local option) and I'm no expert of it, I can't be sure it's an universal solution. If it works for you too, please let me know !

I was dealing with a Prestashop install I got from SVN, since other people had already started working on it. Since the DB settings were done for another server, I changed them in some file in the /config folder. As this folder was already versioned, setting it in svn:ignore would not prevent my local modifications on it from being committed. Here's what I did :

cp config ../cfg_bkp              # copy the files out of the repo
svn rm config                     # delete files both from svn and "physically"
svn propset svn:ignore "config" . # as the files no longer exists, I can add my ignore rule and then...
mv ../cfg_bkp config              # ...bring'em back
svn revert --recursive config     # make svn forget any existing status for the files (they won't be up for deletion anymore)

Now I can run svn add --force . at the repo root without adding my config, even if it's not matching the repo's version (I guess I would have to go through all this again if I modified it one more time, did not test). I can svn update as well without having my files being overwritten or getting any error.


A solution that does not ignore changes in directory properties

I tried to use the solution based on changelist, but I have a couple of issues with it. First my repository has thousand of files, so the changelist to be committed is huge, and my svn status output became way too long and needed to be parsed to be useful. Most important is that I wanted to commit changes that came from a merge, which means they include property changes. When committing a changelist, the svn properties attached to the directory are not committed, so I had to do an extra commit:

svn ci --cl work -m "this commits files from the work changelist only"
svn up
svn ci --depth empty DIR . -m "record merge properties"

You may have to do that for several directories (here I record the properties of DIR and of the current dir .), basically those with a M in the second column when issuing the svn status command.

Solution

I used patches and svn patch. In pseudo-code:

svn diff $IGNORE_FILES > MYPATCH   # get the mods to ignore
svn patch --reverse-diff MYPATCH   # remove the mods
svn ci -m "message"                # check-in files and directory properties
svn patch MYPATCH                  # re-apply the mods

Like other posters, I end up using a script to maintain the list of files to ignore:

#! /usr/bin/env bash

finish() {
    svn patch MYPATCH               # re-apply the mods
}
trap finish EXIT

IGNORE_FILES="\
sources/platform/ecmwf-cca-intel-mpi.xml \
runtime/classic/platform/ecmwf-cca.job.tmpl \
runtime/classic/platform/ecmwf-cca-intel.xml"

svn diff $IGNORE_FILES > MYPATCH # get the mods to ignore
svn patch --reverse-diff MYPATCH # remove the mods

svn "$@"

I typically used it with ci and revert -R ..


svn:ignore is your answer.

Example:

$ svn propset svn:ignore -F .cvsignore .
property 'svn:ignore' set on '.'

svn propset "svn:ignore" "*.xml" .

the *.xml is the pattern of files to ignore; you can use directory names here as well.

참고URL : https://stackoverflow.com/questions/635446/svn-is-there-a-way-to-mark-a-file-as-do-not-commit

반응형