Skip to content

Instantly share code, notes, and snippets.

@SivaCse
Forked from jeserkin/file1
Created October 9, 2017 05:38
Show Gist options
  • Save SivaCse/d747af9f3865f8576cf67509a2625af3 to your computer and use it in GitHub Desktop.
Save SivaCse/d747af9f3865f8576cf67509a2625af3 to your computer and use it in GitHub Desktop.
git rebase example
Eugene@EUGENE-PC /some (master)
$ git log
commit f172c390d5c8a343e6a83842b6ce85a2884cf8e0
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 15:15:21 2012 +0300
Initial commit
Eugene@EUGENE-PC /some (master)
$ git status
# On branch master
nothing to commit (working directory clean)
Eugene@EUGENE-PC /some (master)
$ git branch
* master
Eugene@EUGENE-PC /some (master)
$ ls -ll
total 0
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 LICENSE
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 README
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 index.php
Eugene@EUGENE-PC /some (master)
$ vim index.php
Eugene@EUGENE-PC /some (master)
$ git commit -am 'Added some code to index.php'
[master 968afd9] Added some code to index.php
1 file changed, 5 insertions(+)
Eugene@EUGENE-PC /some (master)
$ git log
commit 968afd998c2afc40acdc93a7d86341dba42676f6
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 17:00:46 2012 +0300
Added some code to index.php
commit f172c390d5c8a343e6a83842b6ce85a2884cf8e0
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 15:15:21 2012 +0300
Initial commit
Eugene@EUGENE-PC /some (master)
$ git checkout -b experiment
Switched to a new branch 'experiment'
Eugene@EUGENE-PC /some (experiment)
$ touch .htaccess
Eugene@EUGENE-PC /some (experiment)
$ git add .
Eugene@EUGENE-PC /some (experiment)
$ git commit -m 'Adding .htaccess for project'
[experiment 916c483] Adding .htaccess for project
0 files changed
create mode 100644 .htaccess
Eugene@EUGENE-PC /some (experiment)
$ git log
commit 916c483ed120e97f819760c0acc17b971916121d
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 17:01:38 2012 +0300
Adding .htaccess for project
commit 968afd998c2afc40acdc93a7d86341dba42676f6
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 17:00:46 2012 +0300
Added some code to index.php
commit f172c390d5c8a343e6a83842b6ce85a2884cf8e0
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 15:15:21 2012 +0300
Initial commit
Eugene@EUGENE-PC /some (experiment)
$ vim .htaccess
Eugene@EUGENE-PC /some (experiment)
$ git commit -am 'Started to work with .htaccess'
[experiment c6f01d4] Started to work with .htaccess
1 file changed, 1 insertion(+)
Eugene@EUGENE-PC /some (experiment)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
Eugene@EUGENE-PC /some (master)
$ vim test.php
Eugene@EUGENE-PC /some (master)
$ git add .
Eugene@EUGENE-PC /some (master)
$ git commit -m 'Added test file for later work'
[master 6ddf59c] Added test file for later work
1 file changed, 2 insertions(+)
create mode 100644 test.php
Eugene@EUGENE-PC /some (master)
$ git log
commit 6ddf59c5a04cfebdfeb243221061f34ed048270c
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 17:03:58 2012 +0300
Added test file for later work
commit 968afd998c2afc40acdc93a7d86341dba42676f6
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 17:00:46 2012 +0300
Added some code to index.php
commit f172c390d5c8a343e6a83842b6ce85a2884cf8e0
Author: Eugene Serkin <jeserkin@gmail.com>
Date: Sat Oct 27 15:15:21 2012 +0300
Initial commit
Eugene@EUGENE-PC /some (master)
$ git checkout experiment
Switched to branch 'experiment'
Eugene@EUGENE-PC /some (experiment)
$ ls -la
total 37
drwxr-xr-x 1 Eugene Administ 4096 Oct 27 17:04 .
dr-xr-xr-x 116 Eugene Administ 65536 Oct 27 16:58 ..
drwxr-xr-x 13 Eugene Administ 4096 Oct 27 17:04 .git
-rw-r--r-- 1 Eugene Administ 29 Oct 27 17:04 .htaccess
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 LICENSE
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 README
-rw-r--r-- 1 Eugene Administ 27 Oct 27 16:59 index.php
Eugene@EUGENE-PC /some (experiment)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 2 commits.
Eugene@EUGENE-PC /some (master)
$ ls -la
total 37
drwxr-xr-x 1 Eugene Administ 4096 Oct 27 17:04 .
dr-xr-xr-x 116 Eugene Administ 65536 Oct 27 16:58 ..
drwxr-xr-x 13 Eugene Administ 4096 Oct 27 17:04 .git
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 LICENSE
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 README
-rw-r--r-- 1 Eugene Administ 27 Oct 27 16:59 index.php
-rw-r--r-- 1 Eugene Administ 45 Oct 27 17:04 test.php
Eugene@EUGENE-PC /some (master)
$ git checkout experiment
Switched to branch 'experiment'
Eugene@EUGENE-PC /some (experiment)
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: Adding .htaccess for project
Applying: Started to work with .htaccess
Eugene@EUGENE-PC /some (experiment)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 2 commits.
Eugene@EUGENE-PC /some (master)
$ ls -la
total 37
drwxr-xr-x 1 Eugene Administ 4096 Oct 27 17:05 .
dr-xr-xr-x 116 Eugene Administ 65536 Oct 27 16:58 ..
drwxr-xr-x 14 Eugene Administ 4096 Oct 27 17:05 .git
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 LICENSE
-rw-r--r-- 1 Eugene Administ 0 Oct 27 16:58 README
-rw-r--r-- 1 Eugene Administ 27 Oct 27 16:59 index.php
-rw-r--r-- 1 Eugene Administ 45 Oct 27 17:05 test.php
Eugene@EUGENE-PC /some (master)
$
Eugene@EUGENE-PC /C/Users/Eugene/Desktop/some (master)
$ git log --oneline --graph --decorate --all
* 02955ad (experiment) Started to work with .htaccess
* 4d544b1 Adding .htaccess for project
* 6ddf59c (HEAD, master) Added test file for later work
* 968afd9 Added some code to index.php
* f172c39 (origin/master, origin/HEAD) Initial commit
Eugene@EUGENE-PC /C/Users/Eugene/Desktop/some (master)
$ git checkout experiment
Switched to branch 'experiment'
Eugene@EUGENE-PC /C/Users/Eugene/Desktop/some (experiment)
$ git log --oneline --graph --decorate --all
* 02955ad (HEAD, experiment) Started to work with .htaccess
* 4d544b1 Adding .htaccess for project
* 6ddf59c (master) Added test file for later work
* 968afd9 Added some code to index.php
* f172c39 (origin/master, origin/HEAD) Initial commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment