OpenSource For You

Grepping through files

-

Searching through source code is a big part of a programmer’s life, and grep is used extensivel­y for this. Git has an inbuilt grep FommDnG Wo sHDUFh WhUoXgh fiOHs WUDFNHG by WhH repository— git grep text. FLx Eug-0234 – OLmLt thH VLzH oI thH DUUDy <Blank line> DHVcULptLo­n DEout Eug-0234 DnG fix #Add rest of the changes to another commit $ gLt DGG mDLn.c $ git commit $ git log # 1ow to Vync my UHpo to D UHmotH (GLthuE) UHpoVLtoUy I cUHDtHG. # Add a remote repo to current repo gLt UHmotH DGG oULgLn httpV://gLthuE.com/t3Um1n4O/pUoMHctnDm­H.gLt $ gLt puVh oULgLn mDVtHU # PuVh mDVtHU EUDnch (DHIDuOt) to UHmotH repo $ git branch –a # List branches

Now, if you want to work on a feature that takes a lot of time, while some other developmen­t goes on in parallel, create a branch for the feature developmen­t as shown below: $ gLt EUDnch IHDtuUH-x $ gLt chHckout IHDtuUH-x

To add some changes related to TODO.txt):

feature-x (such as, adding $ gLt DGG T2D2.txt $ gLt commLt –m “$GGHG T2D2 IoU IHDtuUH-x”

To go back to the master branch and make a few commits (OLNH DGGLng DnG FhDngLng IHw fiOHs), LssXH WhH IoOOowLng commands: $ gLt DGG coUH.c $ gLt commLt –m “MovH coUH IunctLonV to coUH.c” $ gLt DGG mDLn.c $ gLt commLt –m “RHIDctoU mDLn.c”

If you want to work on feature-x, do a git checkout feature-x, WhHn DGG D bXnFh oI fiOHs Wo bXLOG WhH IHDWXUH, DnG then use the following code: $ gLt DGG IHDtuUH.c mDLn.c coUH.c $ gLt commLt (mHVVDgH DV IoOOowV) $GG IHDtuUH-x – OoggHU moGuOH IoU xxx <Blank line> More descriptio­n about the feature

Switch back to the master branch to make some more changes: $ git checkout master $ gLt DGG RE$DME (commLt VomH chDngHV IUom RE$DME) $ gLt commLt –m “ImpUovH RE$DME”

If you then want to merge the

feature-x I developed into

Newspapers in English

Newspapers from India