Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TL Localization - Chapter 7, Git Tools (1,175 words) #69

Merged
merged 7 commits into from Feb 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
164 changes: 82 additions & 82 deletions book/07-git-tools/sections/stashing-cleaning.asc
@@ -1,139 +1,139 @@
[[_git_stashing]] [[_git_stashing]]
=== Stashing and Cleaning === Pag-stash at Paglilinis


Often, when you’ve been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else. Kadalasan, kapag nagtatrabaho ka sa bahagi ng iyong proyekto, ang mga bagay ay nasa isang kalat na estado at gusto mong lumipat ng mga branch para sa isang kaunting trabaho upang magtrabaho sa ibang bagay.
The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. Ang problema ay, hindi mo gustong gumawa ng isang commit sa kalahating natapos na trabaho para lamang makuha mong bumalik sa punto ito mamaya.
The answer to this issue is the `git stash` command. Ang sagot sa isyung ito ay ang utos na `git stash`.


Stashing takes the dirty state of your working directory -- that is, your modified tracked files and staged changes -- and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch). Kumukuha ang pag-stash ng maruming estado ng iyong gumaganang direktoryo -- iyon ay, ang iyong binagong sinusubaybayan na mga file at mga naka-stage na mga pagbabago -- at i-save ito sa isang stack ng mga hindi natapos ng mga pagbabago na maaari mong muling ilapat sa anumang oras (kahit na sa ibang branch).


[NOTE] [TANDAAN]
.Migrating to `git stash push` .Paglilipat sa `git stash push`
==== ====
As of late October 2017, there has been extensive discussion on the Git mailing list, wherein the command `git stash save` is being deprecated in favour of the existing alternative `git stash push`. Sa huling Oktubre 2017, nagkaroon ng malawak na talakayan sa listahan ng pag-mail ng Git, kung saan ang utos na `git stash save` ay hindi na magagamit na pabor sa umiiral na alternatibong `git stash push`.
The main reason for this is that `git stash push` introduces the option of stashing selected _pathspecs_, something `git stash save` does not support. Ang pangunahing dahilan para rito ay ang `git stash push` ay nagpapakilala ng opsyon sa pag-stash ng napiling _pathspecs_, isang bagay na hindi suportado ng `git stash save`.


`git stash save` is not going away any time soon, so don't worry about it suddenly disappearing. Ang `git stash save` ay hindi aalis sa anumang oras sa lalong madaling panahon, kaya huwag mag-alala tungkol dito na biglang mawawala.
But you might want to start migrating over to the `push` alternative for the new functionality. Ngunit maaaring gusto mong simulan ang paglipat sa alternibo na `push` para sa bagong pag-andar.
==== ====


==== Stashing Your Work ==== Pag-stash ng Iyong Trabaho


To demonstrate stashing, you’ll go into your project and start working on a couple of files and possibly stage one of the changes. Upang ipakita ang pag-stash, pupunta ka sa iyong proyekto at simulan ang pagtatrabaho sa isang iilang mga file at posibleng i-stage ang isa sa mga pagbabago.
If you run `git status`, you can see your dirty state: Kung papatakbuhin mo ang `git status`, makikita mo ang iyong maruming estado:


[source,console] [source,console]
---- ----
$ git status $ git status
Changes to be committed: Ang mga pagbabagong dapat i-commit:
(use "git reset HEAD <file>..." to unstage) (gumamit ng "git reset HEAD <file>..." upang mag-unstage)


modified: index.html nabago: index.html


Changes not staged for commit: Mga pagbabago na hindi na-stage para sa commit:
(use "git add <file>..." to update what will be committed) (gumamit ng "git add <file>..." upang ma-update kung ano ang iko-commit)
(use "git checkout -- <file>..." to discard changes in working directory) (gumamit ng "git checkout -- <file>..." upang iwaksi ang mga pagbababago sa iyong tinatrabahong direktoryo)


modified: lib/simplegit.rb nabago: lib/simplegit.rb
---- ----


Now you want to switch branches, but you don’t want to commit what you’ve been working on yet; so you’ll stash the changes. Ngayon nais mong magpalit ng mga branch, ngunit hindi mo pa gusto na i-commit kung ano ang iyong tinatrabaho; kaya i-stash mo ang iyong mga pagbabago.
To push a new stash onto your stack, run `git stash` or `git stash save`: Para mag-push ng isang bagong stash sa iyong stack, patakbuhin ang `git stash` o `git stash save`:


[source,console] [source,console]
---- ----
$ git stash $ git stash
Saved working directory and index state \ Naka-save na gumaganang direktoryo at estado ng indeks \
"WIP on master: 049d078 added the index file" "WIP sa master: 049d078 idinagdag ang indeks na file"
HEAD is now at 049d078 added the index file Ang HEAD ngayon ay nasa 049d078 na nagdagdag sa indeks na file
(To restore them type "git stash apply") (Upang maibalik ang mga ito, magtipa ng "git stash apply")
---- ----


You can now see that your working directory is clean: Maaari mo ng makita na ang iyong gumaganang direktoryo ay malinis:


[source,console] [source,console]
---- ----
$ git status $ git status
# On branch master # Sa branch na master
nothing to commit, working directory clean walang mai-commit, malinis ang gumaganang direktoryo
---- ----


At this point, you can switch branches and do work elsewhere; your changes are stored on your stack. Sa puntong ito, maaari kang magpalit ng mga branch at magtrabaho sa ibang lugar; ang iyong mga pagbabago ay naka-imbak sa iyong stack
To see which stashes you’ve stored, you can use `git stash list`: Upang makita kung anong mga stash na iyong inimbak, maaari kang gumamit ng `git stash list`:


[source,console] [source,console]
---- ----
$ git stash list $ git stash list
stash@{0}: WIP on master: 049d078 added the index file stash@{0}: WIP sa master: 049d078 idinagdag ang indeks na file
stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{1}: WIP sa master: c264051 Ibalik ang "idinagdag ang file_size"
stash@{2}: WIP on master: 21d80a5 added number to log stash@{2}: WIP sa master: 21d80a5 idinagdag ang bilang sa log
---- ----


In this case, two stashes were done previously, so you have access to three different stashed works. Sa kasong ito, dalawang stash ang natapos sa nakaraan, kaya mayroon kang access sa tatlong iba't-ibang naka-stash na mga trabaho.
You can reapply the one you just stashed by using the command shown in the help output of the original stash command: `git stash apply`. Maaari mo muling ilapat ang isa na iyong na-stash sa pamamagitan ng paggamit ng utos na ipanapakita sa output ng tulong ng orihinal na utos ng stash: `git stash apply`.
If you want to apply one of the older stashes, you can specify it by naming it, like this: `git stash apply stash@{2}`. Kung nais mo na ilapat ang isa sa mas lumang mga stash, maaari mong matukoy ito sa pamamagitan ng pagbibigay ng pangalan nito, tulad nito: `git stash apply stash@{2}`.
If you don’t specify a stash, Git assumes the most recent stash and tries to apply it: Kung hindi ka nagtukoy ng isang stash, ipinagpapalagay ng Git ang pinakabago na stash at sinusubukan na ilapat ito:


[source,console] [source,console]
---- ----
$ git stash apply $ git stash apply
On branch master Sa branch master
Changes not staged for commit: Ang mga pagbabago ay hindi na-stage para sa commit:
(use "git add <file>..." to update what will be committed) (gumamit ng "git add <file>..." upang ma-update kung ang mako-commit)
(use "git checkout -- <file>..." to discard changes in working directory) (gumamit ng "git checkout -- <file>..." upang iwaksi ang mga pagbabago sa gumaganang direktoryo)


modified: index.html nabago: index.html
modified: lib/simplegit.rb nabago: lib/simplegit.rb


no changes added to commit (use "git add" and/or "git commit -a") walang naidagdag na mga pagbabago sa commit (gumamit ng "git add" at/o "git commit -a")
---- ----


You can see that Git re-modifies the files you reverted when you saved the stash. Maaari mong makita na ang Git ay nagbabago muli ng mga file na iyong ibinalik kapag ikaw ay nag-save ng stash.
In this case, you had a clean working directory when you tried to apply the stash, and you tried to apply it on the same branch you saved it from. Sa kasong ito, mayroon kang isang malinis na gumaganang direktoryo kapag sinubukan mo na mag-lapat ng stash, at sinubukan mo na ilapat ito sa parehong branch kung saan mo ito si-nave.
Having a clean working directory and applying it on the same branch aren’t necessary to successfully apply a stash. Ang pagkakaroon ng isang malinis na gumaganang direktoryo at paglalapat nito sa parehong branch ay hindi kinakailangan upang matagumpay na maglapat ng isang stash.
You can save a stash on one branch, switch to another branch later, and try to reapply the changes. Maaari mo i-save ang isang stash sa isang branch, palitan sa ibang branch mamaya, at subukan na muling ilapat ang mga pagbabago.
You can also have modified and uncommitted files in your working directory when you apply a stash -- Git gives you merge conflicts if anything no longer applies cleanly. Maaari mo ka ring magkaroon ng mga file na binago o hindi na-commit sa iyong gumaganang direktoryo kapag ikaw ay naglapat ng isang stash -- Binibigyan ka ng Git ng mga kasalungatan sa pag-merge kung hindi na mailalapat nang malinis.


The changes to your files were reapplied, but the file you staged before wasn’t restaged. Ang mga pagbabago sa iyong mga file ay muli ng nailapat, ngunit ang file na naka-stage noon ay hindi na muling ma-stage.
To do that, you must run the `git stash apply` command with a `--index` option to tell the command to try to reapply the staged changes. Upang gawin iyon, dapat mong patakbuhin ang utos na `git stash apply` na may isang opsyon na `--index` upang sabihan ang utos na subukan na muling ilapat ang naka-stage na mga pagbabago.
If you had run that instead, you’d have gotten back to your original position: Kung sa halip ay napatakbo mo ito , naibalik ka sa iyong orihinal na posisyon:


[source,console] [source,console]
---- ----
$ git stash apply --index $ git stash apply --index
On branch master Sa branch master
Changes to be committed: Ang mga pagbabago na i-commit:
(use "git reset HEAD <file>..." to unstage) (gumamit ng "git reset HEAD <file>..." para i-unstage)


modified: index.html nabago: index.html


Changes not staged for commit: Ang mga pagbabago na hindi na-stage para sa commit:
(use "git add <file>..." to update what will be committed) (gumamit ng "git add <file>..." upang mag-update kung ano ang mako-commit)
(use "git checkout -- <file>..." to discard changes in working directory) (gumamit ng "git checkout -- <file>..." upang iwaksi ang mga pagbabago sa gumaganang direktoryo)


modified: lib/simplegit.rb nabago: lib/simplegit.rb
---- ----


The apply option only tries to apply the stashed work -- you continue to have it on your stack. Ang opsyon na apply ay sinusubukan lamang na maglapat ng naka-stash na trabaho -- ituloy mo upang magkaroon ka nito sa iyong stack.
To remove it, you can run `git stash drop` with the name of the stash to remove: Upang matanggal ito, maaari mong patakbuhin ang `git stash drop` na may pangalan ng stash na tatanggalin:


[source,console] [source,console]
---- ----
$ git stash list $ git stash list
stash@{0}: WIP on master: 049d078 added the index file stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{1}: WIP sa master: c264051 Ibinalik ang "idinagdag na file_size"
stash@{2}: WIP on master: 21d80a5 added number to log stash@{2}: WIP sa master: 21d80a5 idinagdag ang bilang sa log
$ git stash drop stash@{0} $ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43) Alisin ang stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
---- ----


You can also run `git stash pop` to apply the stash and then immediately drop it from your stack. Maaari mo ring patakbuhin ang `git stash pop` upang ilapat ang stash at pagkatapos ay kaagad na alisin ito mula sa iyong stack.


==== Creative Stashing ==== Malikhain na Pag-stash


There are a few stash variants that may also be helpful. Mayroong ilang ibang stash na maaari ring kapaki-pakinabang.
The first option that is quite popular is the `--keep-index` option to the `stash save` command. Ang unang opsyon na medyo sikat ay ang opsyon na `--keep-index` sa utos na `stash save`.
This tells Git to not only include all staged content in the stash being created, but simultaneously leave it in the index. Ito ay nagsasabi sa Git na hindi lamang isali ang lahat ng naka-stage na nilalaman sa stash na nilikha, sabay na iwanan ito sa indeks.


[source,console] [source,console]
---- ----
Expand All @@ -142,16 +142,16 @@ M index.html
M lib/simplegit.rb M lib/simplegit.rb


$ git stash --keep-index $ git stash --keep-index
Saved working directory and index state WIP on master: 1b65b17 added the index file Naka-save na gumaganang direktoryo at estado ng indeks WIP sa master: 1b65b17 idinagdag sa indeks na file
HEAD is now at 1b65b17 added the index file Ang HEAD ngayon ay nasa 1b65b17 idinagdag sa indeks na file


$ git status -s $ git status -s
M index.html M index.html
---- ----


Another common thing you may want to do with stash is to stash the untracked files as well as the tracked ones. Iba pang karaniwan na bagay na gugustuhin mo sa stash ay para i-stash ang hindi sinubaybayan na mga file pati na rin ang sinibaybayan.
By default, `git stash` will stash only modified and staged _tracked_ files. Bilang default, ang `git stash` ay mag-stash lamang ng binagong at naka-stage na _tracked_ files.
If you specify `--include-untracked` or `-u`, Git will include untracked files in the stash being created. Kung tinutukoy mo ang `--include-untracked` o `-u`, isasama ng Git ang mga file na hindi sinubaybayan sa nilikhang stash.


[source,console] [source,console]
---- ----
Expand All @@ -161,14 +161,14 @@ M index.html
?? new-file.txt ?? new-file.txt


$ git stash -u $ git stash -u
Saved working directory and index state WIP on master: 1b65b17 added the index file Naka-save na gumaganang direktoryo at estado ng indeks WIP sa master: 1b65b17 idinagdag ang indeks na file
HEAD is now at 1b65b17 added the index file Ang HEAD ngayon ay nasa 1b65b17 na idinagdag ang indeks na file


$ git status -s $ git status -s
$ $
---- ----


Finally, if you specify the `--patch` flag, Git will not stash everything that is modified but will instead prompt you interactively which of the changes you would like to stash and which you would like to keep in your working directory. Sa wakas, kung ikaw ay nagtutukoy ng flag na `--patch`, hindi i-stash ng Git ang lahat na binago ngunit sa halip ay mag-prompt sa iyo kung alin ang mga pagbabago na gusto mong i-stash at kung ano ang gusto mo na panatilihin sa iyong gumaganang direktoryo.


[source,console] [source,console]
---- ----
Expand All @@ -188,9 +188,9 @@ index 66d332e..8bb5674 100644


end end
test test
Stash this hunk [y,n,q,a,d,/,e,?]? y I-stash ang hunk na ito [y,n,q,a,d,/,e,?]? y


Saved working directory and index state WIP on master: 1b65b17 added the index file Naka-save na gumaganang direktoryo at estado ng indeks WIP sa master: 1b65b17 idinagdag ang indeks na file
---- ----


==== Creating a Branch from a Stash ==== Creating a Branch from a Stash
Expand Down