M string.c
?? string
Now you want to switch the branch by an unexpected guest, but you don't want to commit what you did on it, so you stash the changes. To push these new stash into the stack, run git stash.
[jerry @ CentOS project] $ git stash
Đang ghi thư mục làm việc và chỉ mục cơ sở dữ liệu WIP trên master: e86f062 Added my_strcpy function
HEAD is now at e86f062 Added my_strcpy function
Now your working directory is clean and all changes are kept on a stack. Please verify it with the git status command.
[jerry @ CentOS project] $ git status -s
?? string
Now you can safely move the branch and do anything. We can observe a list of stash changes using the git stash list command.
[jerry @ CentOS project] $ git stash list
stash @ {0}: WIP on master: e86f062 Added my_strcpy function
Suppose you have solved the problem with the new customer and you go back to making your unfinished code, you just need to perform the git stash pop command, to move the changes from the stack and put them into Current working directory.
[jerry @ CentOS project] $ git status -s
?? string
[jerry @ CentOS project] $ git stash pop
The above command will produce the following result:
# On the master branch
# Changed but not updated:
# (use "git add ." to update what will be committed)
# (use "git checkout - ." to discard changes in directory working)
#
#
modified: string.c
#
# Untracked files:
# (use "git add ." to include in what will be committed)
#
#
string
không thay đổi thêm vào commit (sử dụng "git add" and / or "git commit -a")
Dropped refs / stash @ {0} (36f79dfedae4ac20e2e8558830154bd6315e72d4)
[jerry @ CentOS project] $ git status -s
M string.c
?? string
According to Tutorialspoint
Previous article: Update activity in Git
Next article: Online Repository in Git