/home/wpollock1/public_html/AJava/RebaseDemo.txt

C:\Users\wpollock\Desktop\Java>md rebasedemo.git

C:\Users\wpollock\Desktop\Java>cd rebasedemo.git

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git init
Initialized empty Git repository in C:/Users/wpollock/Desktop/Java/rebasedemo.git/.git/

C:\Users\wpollock\Desktop\Java\rebasedemo.git>notepad++ ReadMe.txt

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file
with several lines in it,
used to illustrate various Git commands.


C:\Users\wpollock\Desktop\Java\rebasedemo.git>git add .

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git commit -m "Initial Commit"
[master (root-commit) cabfd05] Initial Commit
 1 file changed, 3 insertions(+)
 create mode 100644 ReadMe.txt

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git checkout -b feature
Switched to a new branch 'feature'

C:\Users\wpollock\Desktop\Java\rebasedemo.git>notepad++ ReadMe.txt

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git commit -a -m "changed line 1"
[feature 0b5519a] changed line 1
 1 file changed, 1 insertion(+), 1 deletion(-)

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git commit -a -m "changed line 2"
[feature 7be1233] changed line 2
 1 file changed, 1 insertion(+), 1 deletion(-)

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git commit -a -m "changed line 2"
[feature f1838d7] changed line 2
 1 file changed, 1 insertion(+), 1 deletion(-)

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git checkout master
Switched to branch 'master'

C:\Users\wpollock\Desktop\Java\rebasedemo.git>notepad++ ReadMe.txt

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git commit -a -m "Added two lines at end"
[master 2e4d0bb] Added two lines at end
 1 file changed, 2 insertions(+)

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git mylog
* Commit: 2e4d0bb, Parent(s): cabfd05, Author: Wayne, Date: Tue Feb 9 03:12:22 2021 -0500  (HEAD -> master)
| Added two lines at end
|
|
| * Commit: f1838d7, Parent(s): 7be1233, Author: Wayne, Date: Tue Feb 9 03:10:35 2021 -0500  (feature)
| | changed line 2
| |
| |
| * Commit: 7be1233, Parent(s): 0b5519a, Author: Wayne, Date: Tue Feb 9 03:10:18 2021 -0500
| | changed line 2
| |
| |
| * Commit: 0b5519a, Parent(s): cabfd05, Author: Wayne, Date: Tue Feb 9 03:09:40 2021 -0500
|/  changed line 1
|
|
* Commit: cabfd05, Parent(s): , Author: Wayne, Date: Tue Feb 9 03:08:17 2021 -0500
  Initial Commit


(Notice how branch "feature" has three commits.)

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file
with several lines in it,
used to illustrate various Git commands.

Added some lines in master branch.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git checkout feature
Switched to branch 'feature'

First we will squash the three commits on feature branch into one:

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file                     Made change 1 in feature branch
with several lines in it,                 Made change 2 in feature branch
used to illustrate various Git commands.  Made change 3 in feature branch

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git rebase -i HEAD~3

========================================================================
Editor opens with rebasing script.  Make changes to two lines (replace
"pick" with "squash":

pick 0b5519a changed line 1
squash 7be1233 changed line 2
squash f1838d7 changed line 3

# Rebase cabfd05..f1838d7 onto cabfd05 (3 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#

(After saving and exiting the editor, the script runs.  It opens the
editor at the end to allow you to create a new commit message, showing
the three that will be replace.  Make your changes, save, and exit.)
=========================================================================

[detached HEAD bf37a10] changed lines 1 to 3
 Date: Tue Feb 9 03:09:40 2021 -0500
 1 file changed, 3 insertions(+), 3 deletions(-)
Successfully rebased and updated refs/heads/feature.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git status
On branch feature
nothing to commit, working tree clean

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file                     Made change 1 in feature branch
with several lines in it,                 Made change 2 in feature branch
used to illustrate various Git commands.  Made change 3 in feature branch


C:\Users\wpollock\Desktop\Java\rebasedemo.git>git mylog
* Commit: bf37a10, Parent(s): cabfd05, Author: Wayne, Date: Tue Feb 9 03:09:40 2021 -0500  (HEAD -> feature)
| changed lines 1 to 3
|
|
| * Commit: 2e4d0bb, Parent(s): cabfd05, Author: Wayne, Date: Tue Feb 9 03:12:22 2021 -0500  (master)
|/  Added two lines at end
|
|
* Commit: cabfd05, Parent(s): , Author: Wayne, Date: Tue Feb 9 03:08:17 2021 -0500
  Initial Commit


(Notice how the three old commits on branch feature have been replaced with
one new one!)


The one commit can easily be reviewed with a pull request or patch.  Once
approved, it needs to be merged into the main branch (since in this example,
another commit was added to the main branch just to demonstrate the merge):


C:\Users\wpollock\Desktop\Java\rebasedemo.git>git checkout master
Switched to branch 'master'

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git status
On branch master
nothing to commit, working tree clean

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file
with several lines in it,
used to illustrate various Git commands.

Added some lines in master branch.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git merge feature
Auto-merging ReadMe.txt
CONFLICT (content): Merge conflict in ReadMe.txt
Automatic merge failed; fix conflicts and then commit the result.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git mergetool
Merging:
ReadMe.txt

Normal merge conflict for 'ReadMe.txt':
  {local}: modified file
  {remote}: modified file

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git status
On branch master
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Changes to be committed:
        modified:   ReadMe.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ReadMe.txt.orig


C:\Users\wpollock\Desktop\Java\rebasedemo.git>del ReadMe.txt.orig

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file                     Made change 1 in feature branch
with several lines in it,                 Made change 2 in feature branch
used to illustrate various Git commands.  Made change 3 in feature branch

Added some lines in master branch.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git add .

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git commit -m "rebasing feature branch onto main branch, squashing 3 commits into 1."
[master 28da2dc] rebasing feature branch onto main branch, squashing 3 commits into 1.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git status
On branch master
nothing to commit, working tree clean

C:\Users\wpollock\Desktop\Java\rebasedemo.git>git mylog
*   Commit: 28da2dc, Parent(s): 2e4d0bb bf37a10, Author: Wayne, Date: Tue Feb 9 03:19:28 2021 -0500  (HEAD -> master)
|\  rebasing feature branch onto main branch, squaching 3 commits into 1.
| |
| |
| * Commit: bf37a10, Parent(s): cabfd05, Author: Wayne, Date: Tue Feb 9 03:09:40 2021 -0500  (feature)
| | changed lines 1 to 3
| |
| |
* | Commit: 2e4d0bb, Parent(s): cabfd05, Author: Wayne, Date: Tue Feb 9 03:12:22 2021 -0500
|/  Added two lines at end
|
|
* Commit: cabfd05, Parent(s): , Author: Wayne, Date: Tue Feb 9 03:08:17 2021 -0500
  Initial Commit


(Notice the "diamond" in the history, showing the successful merge.  Here's
the final version of the file

C:\Users\wpollock\Desktop\Java\rebasedemo.git>type ReadMe.txt
This is a sample file                     Made change 1 in feature branch
with several lines in it,                 Made change 2 in feature branch
used to illustrate various Git commands.  Made change 3 in feature branch

Added some lines in master branch.

C:\Users\wpollock\Desktop\Java\rebasedemo.git>