Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Friday, February 17, 2017

Friday, November 18, 2016

Find problematic commit (removed something)

A)
#start bisect
$ git bisect start
#mark the commit you know is good
$ git bisect good fd0a623
#makr the commit you know is bad
$ git bisect bad 256d850


B)
#find string that was removed
$ git grep string_removed

# if not found, mark as bad
$ git bisect bad
# if found, mark as good
$ git bisect good

#repeat  step B until it shows first bad commit


#Once commit found, use reset to go back to original state
$ git bisect reset

Thursday, July 28, 2016

Git web viewer

$ sudo yum install lighttpd

Start web server
$ git instaweb

Stop webserver
$ git instaweb --stop

https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb

Wednesday, July 27, 2016

Git status hide untracked files

$ git status -uno
or
$ git status --untracked-files=no
make it default
$ git config --global status.showUntrackedFiles no
now
$ git status   

Tuesday, May 3, 2016

Make git log --stat to show full path

Make it bigger
$ git log --stat-name-width=200 --stat-width=200

$ git log --name-only --oneline


$ git log --name-only --pretty=format: HEAD^^..HEAD  |  sed '/^$/d'

$ git log --name-only --pretty=format: HEAD^^..HEAD  |  grep -v '^$'

Friday, April 22, 2016

Removing files from a specific commit

Suppose we have the following commits and we want to remove files from the second commit.

~# git log
commit 5e1552bfada408e4e3c86f1d68a50f5be71ab64a
Author: Commiter Name <commiter@git.com.br>
Date:   Fri Apr 22 14:58:59 2016 -0300

    Last commit

commit 3798da6a72e463c7a266518cf898643febab04e3
Author: Commiter Name <commiter@git.com.br>
Date:   Wed Apr 20 21:09:36 2016 -0300

    Second commit

commit 9b8dfcab524810e4ddad2b9516c323a9a6ab3857
Author: Commiter Name <commiter@git.com.br>
Date:   Wed Apr 20 20:57:06 2016 -0300

    First commit


We do git rebase -i with the id from the First commit

~# git rebase -i 9b8dfcab524810e4ddad2b9516c323a9a6ab3857

pick 9b8dfca First commit
e 3798da6 Second commit
pick 5e1552b Last commit

# Rebase 3cc8e8a..5e1552b onto 3cc8e8a
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#

mark to edit
e 3798da6 Second commit


~# git reset --soft HEAD^

Then reset the unwanted files in order to leave them out from the commit:

~# git reset HEAD path/to/unwanted_file

Now commit again, you can even re-use the same commit message:

~# git commit -c ORIG_HEAD 

Blog Archive