Git에 의해 커밋되지 않은 변경 사항을 Master에서 새 지점으로 변경
지점에있을 때 어떻게 커밋되지 않은 변경 사항을 지점 테스트에 적용 할 수 master
있습니까?
테스트 브랜치를 체크 아웃 한 다음 커밋하면됩니다. 다른 지점으로 이동할 때 커밋되지 않은 변경 사항은 손실되지 않습니다.
마스터 지점에 있다고 가정합니다.
git checkout test
git add .
git add deletedFile1
git add deletedFile2
...
git commit -m "My Custom Message"
삭제 된 파일에 대해 잘 모르겠지만 사용할 때 포함되지 않은 것 같습니다. git add .
또한 다음을 수행하여 새 분기를 작성하고 전환 할 수 있습니다.
git checkout -b new_branch
git add .
코드 편집을 시작하기 전에 항상 새 브랜치를 시작하는 것을 잊기 때문에 항상 이것을 사용합니다.
왜 git stash를 사용하지 않습니까? 복사하여 붙여 넣기처럼 더 직관적이라고 생각합니다.
$ git branch
develop
* master
feature1
TEST
$
현재 분기에 이동할 파일이 있습니다.
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: awesome.py
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: linez.py
#
$
$ git stash
Saved working directory and index state \
"WIP on master: 934beef added the index file"
HEAD is now at 934beef added the index file
(To restore them type "git stash apply")
$
$ git status
# On branch master
nothing to commit (working directory clean)
$
$
$ git stash list
stash@{0}: WIP on master: 934beef ...great changes
$
다른 지점으로 이동하십시오.
$ git checkout TEST
그리고 적용
$ git stash apply
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: awesome.py
# modified: linez.py
#
I also like git stash
because I use git flow
, which complains when you want to finish a feature branch whilst having changes still in your working directory.
Just like @Mike Bethany, this happens to me all the time because I work on a new problem while forgetting I am still on another branch. So you can stash your work, git flow feature finish...
, and git stash apply
to new git flow feature start ...
branch.
git checkout TEST
git add file1 file2
git commit
'Programming' 카테고리의 다른 글
CSS 센터 디스플레이 인라인 블록? (0) | 2020.05.14 |
---|---|
React / JSX에 스크립트 태그 추가 (0) | 2020.05.14 |
Excel에서 행을 변경하여 다른 변수를 일정하게 유지하는 방법 (0) | 2020.05.14 |
IE에서 배경 크기 작업을하려면 어떻게해야합니까? (0) | 2020.05.14 |
IntelliJ IDEA의 응용 프로그램 실행 프로필에서 클래스 경로에 디렉토리를 추가하는 방법은 무엇입니까? (0) | 2020.05.14 |