Stash operation in Git
Suppose you are implementing a new feature of your product. Your code is in progress, suddenly a visitor. Because of this, you have to go out for a few hours. You cannot commit this code and cannot throw it away at your changes. So you need some temporary space, where you can keep these local changes and then return to commit it.
In Git, stash operations help you stash edited files, changes, and save them on a stack of uncompleted changes, and from there you can re-apply at any time.
[jerry @ CentOS project] $ git status -s
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
You should read it
May be interested
- Operation Muskox: America was preparing to fight the Soviet Union in the Arcticdespite the fact that geographically, with cold, snow and ice, natural conditions were very favorable for canada in protecting the country's northern border, ottawa was always insecure about this issue.
- Delete operation in Gittom updates the local repository and finds the compiled binary in the src directory. after observing the commit message, he realizes that this code is added by jerry.
- Instructions on how to cross cells in Excelthe operation of dividing 1 cell into 2 diagonal triangle cells with a line in excel is an extremely basic operation and is often performed in the process of creating tables in excel.
- Guide to change the direction of the scrolling page of Touchpad Windows 10to be able to scroll a certain page or window on windows 10, in addition to using the mouse we will perform the operation of moving the finger from top to bottom at touchpad. however, we can also change this default operation with a fairly simple operation.
- How to Fix 'Error 0x00000709: Operation Could Not Be Completed' on Windowsit's frustrating when something as simple as setting up a default printer on windows results in an error. luckily, resolving the operation could not be completed (error 0x00000709) error isn't too difficult.
- Operator in programming Coperator is a symbol that tells the compiler to perform a certain mathematical operation or logical operation. language c has a lot of operators and provides operator types.
- What is air purifier? What is the structure and mechanism of operation?along learn more about the structure, operating principles, features of air purifiers to choose for your home, office work the most appropriate device!
- The Hotmail service has returned to normal operationmicrosoft's hotmail service has returned to normal operation since january 3 after encountering several bugs at the end of the year.
- Simple operations to speed up the Macbookin addition to the flashy and expensive design, the apple imacs, macbooks, mac mini, mac pro are always famous for their incredibly remarkable work speed from thorough and self-contained synchronization. however, it can become 'sluggish' after a period of use if not 'properly' cared for.
- Patch operation in Gitthe patch is a text file, its content is similar to git diff, but in parallel with the code, it also has metadata about commits such as commit ids, dates, commit messages ... we can create a patch from commits and others can apply them to their repository.