Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

TFS의 이력에서 "Get This Version"과 같은 기능을 Git으로 처리한다면?

Visual Studio에서 기존 TFS를 사용했다면 "Get This Version"(Get Specific Version)을 사용해 종종 특정 시점으로 소스 코드를 돌려 본 적이 있을 것입니다. (가령, 이전에 없던 버그가 발생했을 때 어떤 소스 코드의 변경으로 인한 것인지 알 수 없을 때 유용할 수 있습니다.)

git_getthisver_1.png

반면, Git을 사용하는 경우에는 이런 메뉴가 없고, 대신 "Reset"이나 "Revert" 등이 있지만,

git_getthisver_2.png

해당 기능들은 TFS의 "Get This Version"과는 차이가 있습니다.

[초보용] Git 되돌리기( Reset, Revert )
; https://medium.com/nonamedeveloper/%EC%B4%88%EB%B3%B4%EC%9A%A9-git-%EB%90%98%EB%8F%8C%EB%A6%AC%EA%B8%B0-reset-revert-d572b4cb0bd5

(아쉽게도) 비주얼 스튜디오의 Git 메뉴에는 나오지 않지만, 명령행이라면 "git checkout"으로 이를 구현할 수 있는데요, 가령 다음과 같이 commit을 했을 때,

c:\temp\ConsoleApp2> git log
commit 0363a8f6e01fe396d123c12e4124ca50010cd396 (HEAD -> master)
Author: tester <tester@test.com>
Date:   Wed Sep 16 14:07:12 2020 +0900

    3

commit a0d0d229f618a7b0f6efc0f7bd5d7a279155be51
Author: tester <tester@test.com>
Date:   Wed Sep 16 14:06:41 2020 +0900

    2

commit 43751f5c67bdeeffe9d4283af887e5a3dfade8f0
Author: tester <tester@test.com>
Date:   Wed Sep 16 14:06:31 2020 +0900

    1

commit 001abba1b091dfd92627544394f864364ce1e3f3
Author: tester <tester@test.com>
Date:   Wed Sep 16 14:05:49 2020 +0900

    Add .gitignore and .gitattributes.

1번 commit이 되었던 시점으로 솔루션의 소스 코드를 되돌리고 싶다면 이렇게 할 수 있습니다.

c:\temp\ConsoleApp2> git checkout 43751f5c
Note: checking out '43751f5c'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 43751f5 1

git_getthisver_3.png




그렇긴 한데, 사실 관점을 좀 달리해야 합니다. TFS와 Git을 있는 그대로 비교하면 안 되고, Git은 그 나름의 방법으로 해결하는 것이 바람직한데요, 이를 위해 그냥 "branch"를 활용하면 됩니다. 단순히 특정 시점의 commit에 대해 "New Branch..."를 선택하면 되는데, 예를 들어 위에서 했던 것처럼 1번 commit에 대해 branch를 새로 생성하면,

git_getthisver_4.png

구분도 명확하고 이후 다시 최신 소스 코드로 돌아오고 싶을 때도 Visual Studio의 "Team Explorer - Branches" UI에서 제공하는 브랜치 간의 "Checkout" 메뉴로 상태를 쉽게 이전할 수 있습니다. (참고로, 이렇게 곧바로 branch를 생성하는 것은, "git checkout ...[commitid]..." + "git checkout -b ...[branch_name]..."을 한 것과 동일합니다.)




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 9/16/2020]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13533정성태1/18/20242453닷넷: 2206. C# - TCP KeepAlive의 서버 측 구현파일 다운로드1
13532정성태1/17/20242346닷넷: 2205. C# - SuperSimpleTcp 사용 시 주의할 점파일 다운로드1
13531정성태1/16/20242239닷넷: 2204. C# - TCP KeepAlive에 새로 추가된 Retry 옵션파일 다운로드1
13530정성태1/15/20242194닷넷: 2203. C# - Python과의 AES 암호화 연동파일 다운로드1
13529정성태1/15/20242053닷넷: 2202. C# - PublishAot의 glibc에 대한 정적 링킹하는 방법
13528정성태1/14/20242181Linux: 68. busybox 컨테이너에서 실행 가능한 C++, Go 프로그램 빌드
13527정성태1/14/20242123오류 유형: 892. Visual Studio - Failed to launch debug adapter. Additional information may be available in the output window.
13526정성태1/14/20242205닷넷: 2201. C# - Facebook 연동 / 사용자 탈퇴 처리 방법
13525정성태1/13/20242158오류 유형: 891. Visual Studio - Web Application을 실행하지 못하는 IISExpress
13524정성태1/12/20242220오류 유형: 890. 한국투자증권 KIS Developers OpenAPI - GW라우팅 중 오류가 발생했습니다.
13523정성태1/12/20242029오류 유형: 889. Visual Studio - error : A project with that name is already opened in the solution.
13522정성태1/11/20242192닷넷: 2200. C# - HttpClient.PostAsJsonAsync 호출 시 "Transfer-Encoding: chunked" 대신 "Content-Length" 헤더 처리
13521정성태1/11/20242257닷넷: 2199. C# - 한국투자증권 KIS Developers OpenAPI의 WebSocket Ping, Pong 처리
13520정성태1/10/20242001오류 유형: 888. C# - Unable to resolve service for type 'Microsoft.Extensions.ObjectPool.ObjectPool`....'
13519정성태1/10/20242093닷넷: 2198. C# - Reflection을 이용한 ClientWebSocket의 Ping 호출파일 다운로드1
13518정성태1/9/20242356닷넷: 2197. C# - ClientWebSocket의 Ping, Pong 처리
13517정성태1/8/20242198스크립트: 63. Python - 공개 패키지를 이용한 위성 이미지 생성 (pystac_client, odc.stac)
13516정성태1/7/20242305닷넷: 2196. IIS - AppPool의 "Disable Overlapped Recycle" 옵션의 부작용
13515정성태1/6/20242582닷넷: 2195. async 메서드 내에서 C# 7의 discard 구문 활용 사례 [1]
13514정성태1/5/20242255개발 환경 구성: 702. IIS - AppPool의 "Disable Overlapped Recycle" 옵션
13513정성태1/5/20242176닷넷: 2194. C# - WebActivatorEx / System.Web의 PreApplicationStartMethod 특성
13512정성태1/4/20242143개발 환경 구성: 701. IIS - w3wp.exe 프로세스의 ASP.NET 런타임을 항상 Warmup 모드로 유지하는 preload Enabled 설정
13511정성태1/4/20242163닷넷: 2193. C# - ASP.NET Web Application + OpenAPI(Swashbuckle) 스펙 제공
13510정성태1/3/20242099닷넷: 2192. C# - 특정 실행 파일이 있는지 확인하는 방법 (Linux)
13509정성태1/3/20242123오류 유형: 887. .NET Core 2 이하의 프로젝트에서 System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0.
13508정성태1/3/20242141오류 유형: 886. ORA-28000: the account is locked
1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...