Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Wednesday, October 9, 2013

git merge

Here is the procedure while porting kernel from 3.4.5 to 3.10 kernel.

$cd /projects/mobcom_andrwks_ext8/users/arunks/kernel-porting/aosp/

Clone the AOSP kernel,

Now move into 3.4.5 kernel,
$git remote add porting-3.10 /projects/mobcom_andrwks_ext8/users/arunks/kernel-porting/aosp/common
$git fetch porting-3.10

/*Set the renamelimit to make merge complete. Otherwise git merge will

stop rename resolution when default value of renamelimit is reached.*/
$git config merge.renameLimit 999999

Create a local branch with name android-3.10 tracking remotes/origin/experimental/android-3.10

$git merge -s recursive android-3.10

Now resolve all merge conflicts and git add or rm according.

Then do a git commit.

Friday, November 23, 2012

Git advanced topics

I m going to write features of git which I feel are advanced.

1. Editing a commit which is not HEAD

git rebase -i e39f5d5f122029f6e1271^

where e39f5d5f122029f6e1271 is the commit which I want to amend.

Now some thing like this will come, which is self explanatory,


now change those commits  to "edit" from "pick". Save and close.

Now edit those files you want to and do git add for the files.

After that git commit --amend
then,
git rebase --continue

2. Interactive adding of files(git add -i)


3. Git bisecting to find out where bug was introduced.

commands,

git bisect start
git bisect bad                     /* inform git that current commit you are on is broken */
git bisect good [good_commit_id]                   /* inform git about the working commit */

Now git will checkout to the middle of these commit. You have to build and test if bug exits now.
If bug is present, then type

git bisect bad

else 

git bisect good

To finish,



4.  git add only few changes in same file

    git add -p filename.c

5. Git grep on different branches

git grep -n "string here"


Thursday, November 18, 2010

Minimal git commands

Initialize a repository by,

git init

Add files to the repo by,

git add .

git add file

removal,
git rm file

rename,
git mv old new

This will add all the file under the directory recursively.

Now do a base commit,

git commit -a

This will commit all the files to the repository .

To create a new branch for editing,
git checkout -b devel

Commit only required changes
If you have many changes, for example in folders like drivers/video and drivers/sound. And you only want to commit the changes to drivers/video, then git add those files and type git commit without using -a option.

git add drivers/video/
git commit

If your master has grown beyond the point when you took the devel branch, you can update the master and you can rebase the devel branch to master,

git rebase -i master

Have a look here for more doubts about merging issues.
http://stackoverflow.com/questions/449541/how-do-you-merge-selective-files-with-git-merge

configuring the .gitconfig file,
My .gitconfig file looks like this
cat ~/.gitconfig
[user]
name = "Arun Sudhilal"
email = "arun.sudhilal@lntinfotech.com"
[core]
editor = vim
[color]
ui = auto
[merge]
tool = vimdiff

Creating patches,
git format-patch HEAD~1

HEAD^^ == HEAD~2


---
git show
git show --stat
git show --name-status HEAD~3
git show HEAD:file
contents.....

git log
git log HEAD~10..

git log --author=arun
git log --committer=arun
git log --grep="commit.*message.*text"

For expample if i want to grep "frame", then
git log --grep="grame"
git log -S "some code change"
git log file
git grep -e "pattern" -- some/file

git branch name commit
git checkout name
git checkout -b name commit
git checkout -m name
merge outstanding diff onto branch "name", can result in conflict.

git tag -a -m "got somewhere" good

git rebase
moves new work to a new base line

git fetch
Just update the remote, but doesn't update work space

git fetch + git merge = git pull

to apply a patch in you local tree,
git am -3

Pushing to the repositories,
* git push origin will push changes from all local branches to matching branches the origin remote
* git push origin master will push changes from the local master branch to the remote master branch
* git push origin master:staginwill push changes from the local master branch to the remote staging branch if it exists

Recovering lost commits,Sometime by mistake you might have done git reset --hard HEAD^. Then you realise that you need that commit. Dont worry, git has a way to recover your lost commit.

git reflog

Git tracks almost everything you does. If you feels that you have screwed up you repo by rebase, merge or even by reset, you can dig reflog and get it back.

git reflog output may be something like this,
6d2a85e HEAD@{0}: merge 6d2a85e: Fast-forward
28eb495 HEAD@{1}: 28eb49561313ce479f228acea6d25a2bf20166a8: updating HEAD
6d2a85e HEAD@{2}: pull : Fast-forward
6744afe HEAD@{3}: 6744afe5afa033763cdb4e698eea1a5febabae8e: updating HEAD

once you get this you can check with git show which commit you want. For here you can cherry-pic, merge or checkout.


.gitconfig
And this is how my .gitconfig looks like,



Renaming current branch,
git branch -m linux-linaro-tracking

Checkout with the same name as remote,
git co -t remotes/origin/linux-linaro

Suwon, S Korea