Git checkout -p HEAD Regular Expression Search

OK ... running git checkout -p HEADcreatures in a tooltip ...

Discard this piece from the index and the working line [y, n, q, a, d, /, j, J, g, e ,?]?

Where ?shows the help, and /...

/ - hunk search matching given regular expression

So, I wanted to try. I added a line to the file, for example let mySillyString = "Hello, world".

If I do git diff, I can see several files and hunks that are on the working line. (Including sillyStringone).

How to use parameter /to search for my sillyStringhunk.

When I enter /, he issues an invitation

look for regular expression?

I tried several options, but it still just offers the hunk in which it is now located.

sillyString hunk?

git,

, , , .

diff --git a/MyProject/AViewController.swift b/MyProject/AViewController.swift index 1b14a4522..3341eb355 100644
--- a/MyProject/AViewController.swift
+++ b/MyProject/AViewController.swift 

@@ -99,12 +99,6 @@ class AViewController: UIViewController, Str
         print("doing something here")
     }

-    func getImageURL() -> URL? {
-        print("doing something here")
-        print("doing something here")
-        return theImageURL
-    }
-
     func addPopGesture() {
         print("doing something here")

@@ -174,6 +168,12 @@ extension AViewController {

         stackView.addArrangedSubviews(views: someViews)
     }
+
+    private func getImageURL() -> URL? {
+        print("doing something here")
+        print("doing something here")
+        return theImageURL
+    }
 }

 extension AViewController { 

diff --git a/MyProject/AView.swift b/MyProject/AView.swift index b9e3349aa..962e255e2 100644
--- a/MyProject/AView.swift
+++ b/MyProject/AView.swift 

@@ -300,5 +300,7 @@ fileprivate extension UIImage {

         return someData
     }
+
+    let mySillyString = "Hello, world!"  
+
 }

diff , ( ). hunk, .

+4
1

:

/silly , . , , .

:

, . 3 , diff :

diff --git a/Gemfile b/Gemfile
index 751838d..626c553 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,6 +5,8 @@ git_source(:github) do |repo_name|
   "https://github.com/#{repo_name}.git"
 end

+# This is change 1
+
 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 gem 'rails', '~> 5.1.5'
 # Use sqlite3 as the database for Active Record
@@ -18,6 +20,8 @@ gem 'uglifier', '>= 1.3.0'
 # See https://github.com/rails/execjs#readme for more supported runtimes
 # gem 'therubyracer', platforms: :ruby

+# This is change 2
+
 gem 'coffee-rails', '~> 4.2'
 # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
 gem 'turbolinks', '~> 5'
@@ -39,6 +43,8 @@ group :development, :test do
   gem 'selenium-webdriver'
 end

+# This is a silly change
+
 group :development do
   # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
   gem 'web-console', '>= 3.3.0'

, . , "", . , , .

$ git checkout -p HEAD
diff --git a/Gemfile b/Gemfile
index 751838d..626c553 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,6 +5,8 @@ git_source(:github) do |repo_name|
   "https://github.com/#{repo_name}.git"
 end

+# This is change 1
+
 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 gem 'rails', '~> 5.1.5'
 # Use sqlite3 as the database for Active Record
Discard this hunk from index and worktree [y,n,q,a,d,/,j,J,g,e,?]? /silly
@@ -39,6 +43,8 @@ group :development, :test do
   gem 'selenium-webdriver'
 end

+# This is a silly change
+
 group :development do
   # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
   gem 'web-console', '>= 3.3.0'
Discard this hunk from index and worktree [y,n,q,a,d,/,k,K,g,e,?]?

, , , , .

+4

Source: https://habr.com/ru/post/1695162/


All Articles