git stash

KHW·2021년 4월 16일
0

github

목록 보기
4/9

기본적인 git 진행방법

새로운 파일이 추가되면 git status를 누르면 빨간색으로 파일이 언급된다.

git add를 진행하면 git status에서 초록색 파일로 언급된다.

git commit을 진행하고 git status에서는 nothing이라고 뜬다.

git add 후 commit하기전에 stash를 이용하면 저장이 진행되는데 그냥 git stash pop를 할때랑 git stash apply stashList이름은 서로 다른부분은
git stash pop은 stash list가 없어지고
git stash apply stashList이름은 stash list가 진행해도 남아있다.

git stash를 하기전에 초록색 상태로 add되어야한다.


예제프로그램 생성

  1. git init
  2. touch README
  3. git commit -m "init"
  4. git status : commit한 상태이므로 아무것도 없다.


작업내용 담기

  1. touch new_file
  2. git status : 새로운 new_file 빨간색 존재
  3. git add new_file : add로 추가
  4. git status : 초록색으로 존재
  5. git stash : stash 명령어 실행
  6. git stash list : 해당 stash가 존재

하던일을 다시 불러오기

pop 사용

1.git stash pop : 다시 복귀
2. git stash list : stash 내용은 없어진다.
3. git status : add 상태로 유지된 파일들 존재


apply 사용

  1. git stash list : stash존재
  2. git stash apply stash@{0} : pop과 유사하게 복구
  3. git stash list : pop과 다르게 stash가 복구해도 존재
  4. git status : 복구한 new_file

profile
나의 하루를 가능한 기억하고 즐기고 후회하지말자

0개의 댓글