Templee_0302) Git Stash

μ˜€λ²”μ€€Β·2021λ…„ 3μ›” 3일
0

2nd Team Project : Templee

λͺ©λ‘ 보기
6/12

Please commit your changes or stash them before you merge.

I tried to pull the new version of code
my member uploaded

but faced above message

🧑 Solution : 'git stash' > 'git pull [rep address]'

What is 'git stash?'

let's say you were working with muliple branch

you were working in 'exp' branch

Now you had to move to 'master' branch and work there


The problem is that,
if you do not 'git add .' or 'git commit -m" your current work
in 'exp' branch ,

it still affects you even after you move to 'master' branch

after you move to 'git master', 'git status'
you will see an error message that
" you have to commit !"


Then what is 'git stash' ?

it lets you hide the current work, and
get back to most recent commit

and most recent work is put into 'git stash list'
which contains all the 'work' you put
'git stash'ed


after 'git stash'
'git status'

you will see an message
"nothing to commit"

and after that, nothing will bother you
working in 'master' branch


To get back to work
'git stash apply'


actually 'git stash apply' means
you are applying most recent work saved in
'git stash list'


and unless you don't delete the 'stashed' work,
it will still stay in 'git stash list'


To delete the 'stashed' work in 'git stash list' ,

'git stash drop' : delete the most recent work saved in 'git stash list'


What is the other example of 'git stash' ?

let's say you were working on sth,
but you want to get back to most recent commit

then,
1) 'git stash' : put your current work into 'git stash list'
2) git reset --HEAD : go back to most recent commit
do the work
3) git stash apply : bring back the work you were doing
4) git stash drop : remove current work from 'git stash list'

profile
Dream of being "물빡개" ( Go abroad for Dance and Programming)

0개의 λŒ“κΈ€