mi茅rcoles, 9 de diciembre de 2020

GIT Demystifying part 15, Cherry-pick 馃崚馃憣

GIT Demystifying part 15, Cherry-pick 馃崚馃憣


 With cherry pick, git can bring the data of a determined commit. On this simple sample, is shown a tree with a master branch and a branch where features are developed and added on each commit, this is a branch where the data of an specific commit will be extracted to be merged with the master, but only a specific feature, not necesarily the cumulative features of the branch. 

Create the example Tree





Do the cherry-pick 馃崚馃憣, the intention is take the feature-ab and only this feature from the branch-cherry-pick, to be integrated to the master branch.

In this case this feature ab is represented as file2:a and file2:b.

The conflict is solved and then commited. this finish the cherry-picking. So now the master branch has the feature-ab bringed from the cherry-pick branch. and the tree don´t register the join under branches only by the default message of the cherry-pick commit.

This strategy of integrate this specific feature into the master is only to illustrate the posibility of take an specific feature from a list of them into the current master. 

  To perform a better strategy about the develop of software products with diferent versions and limits of each version, is importan maintain the master branch as clean as posible of features, and only add features to master that are strictilly necesary for the product, and work on branches according to the each specific features.

note: In this article Why not use it say that is not recomendable to use it, basically by lost of traceability under determined circunstances.


Let´s do a more complex scenario trying to find diferences between git merge vs git cherry-pick.


command line procedure

$ git init
Initialized empty Git repository in C:/Users/bext/Documents/workspaceSTS448/gitLab01/.git/
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git add f*
warning: LF will be replaced by CRLF in file1.
The file will have its original line endings in your working directory
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit --help
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit -m "c1"
[master (root-commit) eb0c0fc] c1
 1 file changed, 2 insertions(+)
 create mode 100644 file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* eb0c0fc (HEAD -> master) c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git add f*
warning: LF will be replaced by CRLF in file1.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in file2.
The file will have its original line endings in your working directory
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit -am "c2"
[master 61bc9c4] c2
 2 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* 61bc9c4 (HEAD -> master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git branch air
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git checkout air
Switched to branch 'air'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ git add f*
warning: LF will be replaced by CRLF in file1.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in file2.
The file will have its original line endings in your working directory
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ git commit -m "air"
[air adba99a] air
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ logg
* adba99a (HEAD -> air) air
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ git checkout master
Switched to branch 'master'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git branch water
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git branch fire
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git branch ground
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git checkout water
Switched to branch 'water'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ logg
* adba99a (air) air
* 61bc9c4 (HEAD -> water, master, ground, fire) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ git add f*
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ git commit -m "water"
[water 492e5ce] water
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ logg
* 492e5ce (HEAD -> water) water
| * adba99a (air) air
|/
* 61bc9c4 (master, ground, fire) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ git checkout ground
Switched to branch 'ground'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git add f*
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git commit -m "ground"
[ground 3e88a2c] ground
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ logg
* 3e88a2c (HEAD -> ground) ground
| * 492e5ce (water) water
|/
| * adba99a (air) air
|/
* 61bc9c4 (master, fire) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git checkout fire
Switched to branch 'fire'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ cat file1
file1
A-B
fire
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ cat file2
file2
C
fire
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ git add f*
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ git commit -m "file"
[fire cfb2981] file
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ logg
* cfb2981 (HEAD -> fire) file
| * 3e88a2c (ground) ground
|/
| * 492e5ce (water) water
|/
| * adba99a (air) air
|/
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ logg
* cfb2981 (HEAD -> fire) file
| * 3e88a2c (ground) ground
|/
| * 492e5ce (water) water
|/
| * adba99a (air) air
|/
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ git commit -m "fireV1.0"
On branch fire
Changes not staged for commit:
        modified:   file1
        modified:   file2
no changes added to commit
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ git commit -am "fireV1.0"
[fire d71ddf8] fireV1.0
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ logg
* d71ddf8 (HEAD -> fire) fireV1.0
* cfb2981 file
| * 3e88a2c (ground) ground
|/
| * 492e5ce (water) water
|/
| * adba99a (air) air
|/
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (fire)
$ git checkout air
Switched to branch 'air'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ cat file2
file2
C
air
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ git commit -am "airV1.0"
[air 23a0b49] airV1.0
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ logg
* 23a0b49 (HEAD -> air) airV1.0
* adba99a air
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
| * 3e88a2c (ground) ground
|/
| * 492e5ce (water) water
|/
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (air)
$ git checkout water
Switched to branch 'water'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ git commit -am "waterV1.0"
[water 01c630f] waterV1.0
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ logg
* 01c630f (HEAD -> water) waterV1.0
* 492e5ce water
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
| * 3e88a2c (ground) ground
|/
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (water)
$ git checkout ground
Switched to branch 'ground'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git commit -am "groundV1.0"
[ground 1cde227] groundV1.0
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ logg
* 1cde227 (HEAD -> ground) groundV1.0
* 3e88a2c ground
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 (master) c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ checkout master
bash: checkout: command not found
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git checkout master
Switched to branch 'master'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file1
file1
A-B
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file2
file2
C
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file2
file2
C
D
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit -am "add D"
[master 617b85c] add D
 2 files changed, 2 insertions(+), 1 deletion(-)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* 617b85c (HEAD -> master) add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file2
file2
C
D
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file1
file1
A-B-file2:D
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git status
On branch master
nothing to commit, working tree clean
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit -am "add E"
[master e0cb0f0] add E
 2 files changed, 2 insertions(+), 1 deletion(-)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* e0cb0f0 (HEAD -> master) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git branch exclusiveFeature
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi fileExclusive
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git add f*
warning: LF will be replaced by CRLF in fileExclusive.
The file will have its original line endings in your working directory
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ ls
file1  file2  fileExclusive  gitLab01.iml  src/
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit -am "add exclusive feature"
[master fcba656] add exclusive feature
 2 files changed, 3 insertions(+)
 create mode 100644 fileExclusive
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* fcba656 (HEAD -> master) add exclusive feature
* e0cb0f0 (exclusiveFeature) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git checkout exclusiveFeature
Switched to branch 'exclusiveFeature'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ logg
* fcba656 (master) add exclusive feature
* e0cb0f0 (HEAD -> exclusiveFeature) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ git checkout master
Switched to branch 'master'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git reset --hard exclusiveFeature
HEAD is now at e0cb0f0 add E
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* e0cb0f0 (HEAD -> master, exclusiveFeature) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file1
file1
A-B-file2:D-file2:E
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ cat file2
file2
C
D
E
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ ls
file1  file2  gitLab01.iml  src/
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git checkout exclusiveFeature
Switched to branch 'exclusiveFeature'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ vi fileExclusive
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ ls
file1  file2  fileExclusive  gitLab01.iml  src/
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ logg
* e0cb0f0 (HEAD -> exclusiveFeature, master) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ git add f*
warning: LF will be replaced by CRLF in fileExclusive.
The file will have its original line endings in your working directory
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ git add -am "add exclusiveFeature"
error: unknown switch `a'
usage: git add [<options>] [--] <pathspec>...
    -n, --dry-run         dry run
    -v, --verbose         be verbose
    -i, --interactive     interactive picking
    -p, --patch[=<patch-mode>]
                          select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    --renormalize         renormalize EOL of tracked files (implies -u)
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run
    --chmod (+|-)x        override the executable bit of the listed files

bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ git commit -am "add exclusiveFeature"
[exclusiveFeature d036688] add exclusiveFeature
 2 files changed, 3 insertions(+)
 create mode 100644 fileExclusive
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ logg
* d036688 (HEAD -> exclusiveFeature) add exclusiveFeature
* e0cb0f0 (master) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ vi fileExclusive
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ git commit -am "add exclusiveFeatureB"
warning: LF will be replaced by CRLF in fileExclusive.
The file will have its original line endings in your working directory
[exclusiveFeature 37a9d8e] add exclusiveFeatureB
 2 files changed, 2 insertions(+), 2 deletions(-)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ logg
* 37a9d8e (HEAD -> exclusiveFeature) add exclusiveFeatureB
* d036688 add exclusiveFeature
* e0cb0f0 (master) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (exclusiveFeature)
$ git checkout master
Switched to branch 'master'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ ls
file1  file2  gitLab01.iml  src/
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* 37a9d8e (exclusiveFeature) add exclusiveFeatureB
* d036688 add exclusiveFeature
* e0cb0f0 (HEAD -> master) add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git commit -am "add F"
[master 335d36b] add F
 2 files changed, 2 insertions(+)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
* 335d36b (HEAD -> master) add F
| * 37a9d8e (exclusiveFeature) add exclusiveFeatureB
| * d036688 add exclusiveFeature
|/
* e0cb0f0 add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git bundle create /tmp/cherrypicklab --all
Enumerating objects: 59, done.
Counting objects: 100% (59/59), done.
Delta compression using up to 12 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (59/59), 3.70 KiB | 421.00 KiB/s, done.
Total 59 (delta 5), reused 0 (delta 0)
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git merge exclusiveFeature
Auto-merging file1
CONFLICT (content): Merge conflict in file1
Automatic merge failed; fix conflicts and then commit the result.
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ git diff
diff --cc file1
index f365038,d980efb..0000000
--- a/file1
+++ b/file1
@@@ -1,3 -1,3 +1,7 @@@
  file1
  A-B-file2:D-file2:E
++<<<<<<< HEAD
 +file2:F
++=======
+ fileExclusive:A-fileExclusiveB
++>>>>>>> exclusiveFeature
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)
Changes to be committed:
        new file:   fileExclusive
Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   file1

bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ logg
* 335d36b (HEAD -> master) add F
| * 37a9d8e (exclusiveFeature) add exclusiveFeatureB
| * d036688 add exclusiveFeature
|/
* e0cb0f0 add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ git commit
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
U       file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ git add fi*
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master|MERGING)
$ git commit
[master f4eb0d1] Merge branch 'exclusiveFeature'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ logg
*   f4eb0d1 (HEAD -> master) Merge branch 'exclusiveFeature'
|\
| * 37a9d8e (exclusiveFeature) add exclusiveFeatureB
| * d036688 add exclusiveFeature
* | 335d36b add F
|/
* e0cb0f0 add E
* 617b85c add D
| * 1cde227 (ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git checkout groung
error: pathspec 'groung' did not match any file(s) known to git
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (master)
$ git checkout ground
Switched to branch 'ground'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ logg
*   f4eb0d1 (master) Merge branch 'exclusiveFeature'
|\
| * 37a9d8e (exclusiveFeature) add exclusiveFeatureB
| * d036688 add exclusiveFeature
* | 335d36b add F
|/
* e0cb0f0 add E
* 617b85c add D
| * 1cde227 (HEAD -> ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git cherry-pick f4eb0d1 -m 1
error: could not apply f4eb0d1... Merge branch 'exclusiveFeature'
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ git status
On branch ground
You are currently cherry-picking commit f4eb0d1.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
Changes to be committed:
        new file:   fileExclusive
Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   file1

bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ vi file2
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ git cherry-pick --abort
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ logg
*   f4eb0d1 (master) Merge branch 'exclusiveFeature'
|\
| * 37a9d8e (exclusiveFeature) add exclusiveFeatureB
| * d036688 add exclusiveFeature
* | 335d36b add F
|/
* e0cb0f0 add E
* 617b85c add D
| * 1cde227 (HEAD -> ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git merge master
Auto-merging file2
CONFLICT (content): Merge conflict in file2
Auto-merging file1
CONFLICT (content): Merge conflict in file1
Automatic merge failed; fix conflicts and then commit the result.
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git diff
diff --cc file1
index 9303505,61d631b..0000000
--- a/file1
+++ b/file1
@@@ -1,4 -1,4 +1,10 @@@
  file1
++<<<<<<< HEAD
 +A-B
 +file2:ground
 +file2:groundB
++=======
+ A-B-file2:D-file2:E
+ file2:F
+ fileExclusive:A-fileExclusiveB
++>>>>>>> master
diff --cc file2
index 7797b0f,5b8b878..0000000
--- a/file2
+++ b/file2
@@@ -1,4 -1,5 +1,10 @@@
  file2
  C
++<<<<<<< HEAD
 +ground
 +groundB
++=======
+ D
+ E
+ F
++>>>>>>> master
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git diff --ours
* Unmerged path file1
diff --git a/file1 b/file1
index 9303505..d6502d0 100644
--- a/file1
+++ b/file1
@@ -1,4 +1,10 @@
 file1
+<<<<<<< HEAD
 A-B
 file2:ground
 file2:groundB
+=======
+A-B-file2:D-file2:E
+file2:F
+fileExclusive:A-fileExclusiveB
+>>>>>>> master
* Unmerged path file2
diff --git a/file2 b/file2
index 7797b0f..0a3a196 100644
--- a/file2
+++ b/file2
@@ -1,4 +1,10 @@
 file2
 C
+<<<<<<< HEAD
 ground
 groundB
+=======
+D
+E
+F
+>>>>>>> master
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git diff --theirs
* Unmerged path file1
diff --git a/file1 b/file1
index 61d631b..d6502d0 100644
--- a/file1
+++ b/file1
@@ -1,4 +1,10 @@
 file1
+<<<<<<< HEAD
+A-B
+file2:ground
+file2:groundB
+=======
 A-B-file2:D-file2:E
 file2:F
 fileExclusive:A-fileExclusiveB
+>>>>>>> master
* Unmerged path file2
diff --git a/file2 b/file2
index 5b8b878..0a3a196 100644
--- a/file2
+++ b/file2
@@ -1,5 +1,10 @@
 file2
 C
+<<<<<<< HEAD
+ground
+groundB
+=======
 D
 E
 F
+>>>>>>> master
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git merge --help
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git merge --abort
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ logg
*   f4eb0d1 (master) Merge branch 'exclusiveFeature'
|\
| * 37a9d8e (exclusiveFeature) add exclusiveFeatureB
| * d036688 add exclusiveFeature
* | 335d36b add F
|/
* e0cb0f0 add E
* 617b85c add D
| * 1cde227 (HEAD -> ground) groundV1.0
| * 3e88a2c ground
|/
| * 01c630f (water) waterV1.0
| * 492e5ce water
|/
| * 23a0b49 (air) airV1.0
| * adba99a air
|/
| * d71ddf8 (fire) fireV1.0
| * cfb2981 file
|/
* 61bc9c4 c2
* eb0c0fc c1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git cherry-pick e0cb0f0
error: could not apply e0cb0f0... add E
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ git status
On branch ground
You are currently cherry-picking commit e0cb0f0.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   file1
        both modified:   file2
no changes added to commit (use "git add" and/or "git commit -a")
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ git diff
diff --cc file1
index 9303505,690660f..0000000
--- a/file1
+++ b/file1
@@@ -1,4 -1,2 +1,8 @@@
  file1
++<<<<<<< HEAD
 +A-B
 +file2:ground
 +file2:groundB
++=======
+ A-B-file2:D-file2:E
++>>>>>>> e0cb0f0... add E
diff --cc file2
index 7797b0f,2ad95c6..0000000
--- a/file2
+++ b/file2
@@@ -1,4 -1,4 +1,9 @@@
  file2
  C
++<<<<<<< HEAD
 +ground
 +groundB
++=======
+ D
+ E
++>>>>>>> e0cb0f0... add E
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ vi file1
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|CHERRY-PICKING)
$ git cherry-pick --abort
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground)
$ git merge e0cb0f0
Auto-merging file2
CONFLICT (content): Merge conflict in file2
Auto-merging file1
CONFLICT (content): Merge conflict in file1
Automatic merge failed; fix conflicts and then commit the result.
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git diff
diff --cc file1
index 9303505,690660f..0000000
--- a/file1
+++ b/file1
@@@ -1,4 -1,2 +1,8 @@@
  file1
++<<<<<<< HEAD
 +A-B
 +file2:ground
 +file2:groundB
++=======
+ A-B-file2:D-file2:E
++>>>>>>> e0cb0f0
diff --cc file2
index 7797b0f,2ad95c6..0000000
--- a/file2
+++ b/file2
@@@ -1,4 -1,4 +1,9 @@@
  file2
  C
++<<<<<<< HEAD
 +ground
 +groundB
++=======
+ D
+ E
++>>>>>>> e0cb0f0
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git merge --help
bext@DESKTOP-NLF0058 MINGW64 ~/Documents/workspaceSTS448/gitLab01 (ground|MERGING)
$ git cherry-pick --help

Before of mergin or Cherrying we do a backup with
$ git bundle create /tmp/cherrypicklab --all

in order to resume this work. we use the command

git clone /tmp/cherrypicklab newFolder

eot

No hay comentarios:

Publicar un comentario