Showing posts with label Controle de Versão. Show all posts
Showing posts with label Controle de Versão. Show all posts

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 

Monday, November 9, 2015

Git ignore end of line (eol CRLF), ignore space changes

$ git diff --ignore-space-at-eol 
or

$ git diff --ignore-space-change
or

$ git diff --ignore-all-space

Tuesday, May 12, 2015

Meu .gitconfig

.gitconfig

[user]
        name = Thiago Masaki
        email = meu@email.com.br
[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true
[color "status"]
  added = green
  changed = red bold
  untracked = magenta bold
[color "branch"]
  remote = yellow
#[core]
#  autocrlf = false
#  eol = lf
[diff]
        tool = meld
[difftool]
        prompt = false
[alias]
        d = difftool
        dm = difftool -y -t meld
        dv = difftool -y -t vimdiff
 lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

Thursday, January 30, 2014

Ferramenta de comparação de código gratis alternativa ao eclipse (MELD)

Ótima alternativa o eclipse para comparar arquivos visualmente.
http://meldmerge.org/

Friday, August 20, 2010

Tig - Git text mode Browser

Key Action
mSwitch to main view.
dSwitch to diff view.
lSwitch to log view.
pSwitch to pager view.
tSwitch to (directory) tree view.
fSwitch to (file) blob view.
BSwitch to blame view.
HSwitch to branch view.
hSwitch to help view
SSwitch to status view
cSwitch to stage view

Wednesday, April 7, 2010

Controle de versões Git - Tutorial Resumido dos principais usos do dia dia

**************************************************
SETTING UP THE REPOSITORIES

#############################################
Creating repository (local and master)

# ssh master

If you don't have internal_git folder create

# mkdir -p ~/internal_git/.git && cd ~/internal_git/.git

# git init --bare

To make your repositorie visible the master/git web site

# touch git-daemon-export-ok

Edit the descripition to be viewed in the website

# echo "My project bla" > description

# exit ( or CTRL + D to close connection to master)

Change to your projects folder

# cd

Create and initialize the new project folder

# mkdir && cd && git init

Add your repository in master as the origin remote repository (This step is only required once)

# git remote add origin master:internal_git/.git

Create the files for the project ( .c etc.. )

Add each file you want to have in you Git Rep

# git add .c

or add all the files if you prefer

# git add -A

Commit to your local repositorie

# git commit -m "My first commit message"

Push to the remote repository

# git push origin master

(only in the first time you need to specify the remote origin and the branch master)
Other times you need use just # git push

############################################
Adding other people's repository

# git remote add master:/home//internal_git/.git

###########################################

Getting other people's updates

# git fetch

See the commits

# git log /master

See the differences between yours and other rep

# git diff /master

Get the other updates and merge with you local rep

# git rabase /master

#############################################
Creating your remote repository based on other's repository

# ssh master

# cd ~/internal_git

# git clone --bare /home//internal_git/.git

# exit ( or CTRL + D to close connection to master)

# cd

# git clone master:internal_git/.git


*******************************************************
WORKING AND COMMITING

########################################################

Edit your files

Check the modified lines not commited

# git diff

Add the files you want to commit
--> git add -u (Add files that are modified)
--> git add -A (Add all files)
--> git add (Add only the files you want>

If you want check the modified lines in stagin area (files added to be commited)

# git diff --cached

If you want to cancel add

# git reset HEAD

Use

# git commit -m "message for the commit"

or to use your default editor to edit the message

# git commit

If you want to cancel commit

git reset HEAD^1

If you want to cancel commit reverting your files to previous version

git reset HEAD^1 --hard

If you are satisfied with you changes push to your remote repository on master

git push

#############################################################
Editing commits

If you want to fix the last commit

Add the files modified you want to attach to the last commit

# git add

Use commit amend to commit to the last commit

# git commit --amend

If you want to edit a commit that is not the last one

get the commit ID

# git log

You will see something like this

commit 38135a7503488b7bbc2790f9eec9af1c7006bf33
Author: Thiago Ribeiro Masaki
Date: Fri Mar 12 11:41:39 2010 -0300

Bug fixed in bla

commit d908bebc1e5fd9a6f1eb2aa50d290fdecaafa05e
Author: Thiago Ribeiro Masaki
Date: Fri Mar 12 11:32:40 2010 -0300

ABCD XYZ

commit e03551ae496d4d36def9e54210fcf0ddf348eb85
Author: Thiago Ribeiro Masaki
Date: Fri Mar 12 10:48:38 2010 -0300

Second Commit

commit 271faec25fc2df0907c8e6f80ee89b1627da317e
Author: Thiago Ribeiro Masaki
Date: Fri Mar 12 10:47:19 2010 -0300

Initial Commit

Now use git rebase interactive in a commit previous to the commit you want to edit

for example commit ABCD XYZ get the id for Second Commit

# git rebase -i 271faec25fc2df0907c8e6f80ee89b1627da317e

replace the string pick with edit on the line of the commit you want to edit

Edit the files you want

# git add

# git commit --amend

# git rebase --continue

Update the remote repository using force update (-f)

# git push -f




Ver uma versao de um arquivo

Por exemplo:
git cat-file blob HEAD^^^:some/file.c
git cat-file blob ':some/file.c
ou
git show HEAD^^^:some/file.c
git show ':some/file.c


Removing a branch from your remote repo is a little bit different from removing it locally. It’s all about the colon:
git push :heads/
Example: git push origin :heads/some-branch removes some-branch from the remote repo (apparently git push origin :some-branch works as well).

Get the list of remote branchs

git branch -r

download a remote branch

git checkout -b /

Ex. git checkout -b work origin/work

baixar mudanças

git pull
or
git pull --rebase (the same as) git rebase




git fetch -p
git branch -rd public/master
git revert --no-commit  
grep -s -n --color=always "Trcapp(.*);" $(git ls-files -m)
git rebase -Xtheirs origin/master  (keep my local files as is)
git rebase -Xours origin/master  (keep their remote files as is)

git merge -Xours origin/master  (keep their remote files as is)

Monday, March 1, 2010

Subversion

atualizando tudo ignorando mudanças locais
# svn update ou # svn up -r (para uma revisao especifica)
# svn revert --recursive .


ver versão
# svn info

ver aterações em colorido
# svn diff | colordiff | less -R

mostra o autor que alterou cada linha do arquivo.

svn blame | less

buscar "#define EINA_LIST_FOREACH(" sem procurar nos diretorios escondidos .svn

grep --exclude="*\.svn*" -R -A 5 "\#define EINA_LIST_FOREACH(" *


Para gerar patch

svn diff > meupatch.diff

Ver patch colorido

cat meupatch.diff | colordiff | less

para aplicar patch a copia local

patch -p0 -i meupatch.diff

Git SVN
Referencia: Manual do Webkit

cd WebKit
git svn init -T trunk http://svn.webkit.org/repository/webkit
git update-ref refs/remotes/trunk origin/master [svn-remote "svn"]
url = http://svn.webkit.org/repository/webkit
    fetch = trunk:refs/remotes/trunk

git svn fetch
git svn rebase
If you don't fetch new revisions from Subversion very often and find fetching them one by one too slow, you can modify the svn section in your .git/config file to point directly to the refs/remotes/origin/master rather then refs/remotes/trunk which is how it is set up by default. In this case 'git svn fetch' will be way faster if done after "git fetch" or "git pull", since it'll realize it already has all the revisions locally. Edit your svn entry to look like this: [svn-remote "svn"] url = http://svn.webkit.org/repository/webkit fetch = trunk:refs/remotes/origin/master and then re-build the svn index by doing 'git svn fetch' once.


Referencia: Multiple branches using git-svn
Now, we want to add a second remote branch to our local git. To do this, edit your .git/config file. You've probably got soemthing like this in there:
[svn-remote "svn"] url = svn+ssh://your-server/home/svn/project-name/trunk
 fetch = :refs/remotes/git-svn
To track a second branch (for this example, it's "branches/3.4.x"), you want to add:
[svn-remote "svn34"] url = svn+ssh://your-server/home/svn/project-name/branches/3.4.x 
fetch = :refs/remotes/git-svn-3.4
You're just adding a new svn-remote stanza with a new svn-remote name, url, and fetch target.
Next, we want to pull that branch:
git-svn fetch svn34 -r MMMM
Again, pick for the MMMM revision a value that's a) somewhat recent, or you'll wait forever, and b) actually on the branch you want to retrieve.
Now, 'git branch -a' should show a new remote branch named git-svn-3.4. You don't want to mess with this remote branch, so we'll want a local master to edit and/or branch from:
git checkout git-svn-3.4 git checkout -b master-3.4.x
Now we've got a new master-3.4.x that can be used for git-svn rebase and dcommit just as your old master could. From here, cherry-pick the patches you want to backport to your branch, and then dcommit them back to svn.


Resetar configurações SVN
# rm -rf .git/svn
Pegar todos os branchs
# git svn fetch --fetch-all

Blog Archive