sghazagh
Posts: 8
Joined: Wed Sep 19, 2012 9:27 pm

Raspberry PI Linux GIT

Mon Feb 20, 2017 10:03 pm

Hi All,
I have a question which I thought here is the best place to ask.
I deal with Raspberry Linux source to compile the Kernel with my own changes.

As a clean install, I normally clone the main repository as per documentation:

Code: Select all

git clone --depth=1 https://github.com/raspberrypi/linux
So I change some of my stuff and do the compile.So far , so good!

If I want to do the compile , for instance a month later, I need to get the latest kernel source but keep my changes.
What is the best way to update my local GIT source with changes on remote and then apply my changes?

I generally do this :
git fetch origin
git reset --hard origin/master <or branch>
git clean -f -d

but this normally does not work and I loose my changes and have to apply them again!
can you please advise what I have to do to get my local GIT get update from latest changes on remote and then I can apply my changes back to updated one?

------------------
Update:
I have done this and I think is ok. Can you please someone with more experience confirm if this is the best approach?!
Thanks
git add <my files>
git commit -m "My changes..."
git fetch origin
git reset --hard origin/master <or branch for example I did : origin/rpi-4.4.y>
git merge
git checkout <my commit ID> <path to my file>

asavah
Posts: 373
Joined: Thu Aug 14, 2014 12:49 am

Re: Raspberry PI Linux GIT

Mon Feb 20, 2017 10:56 pm

try:
git pull --rebase
without removing your changes, it may just work (tm)

more info https://git-scm.com/book/ch3-6.html

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 8918
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Raspberry PI Linux GIT

Tue Feb 21, 2017 7:03 am

You can break pull --rebase into two with
Git fetch
Git rebase
assuming you checked out your branch as a tracking branch. Otherwise
Git rebase origin/master
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: Raspberry PI Linux GIT

Tue Feb 21, 2017 8:04 am

sghazagh wrote: I have done this and I think is ok. Can you please someone with more experience confirm if this is the best approach?!
Thanks
git add <my files>
git commit -m "My changes..."
git fetch origin
git reset --hard origin/master <or branch for example I did : origin/rpi-4.4.y>
git merge
git checkout <my commit ID> <path to my file>
Using git reset feels like you're probably doing something wrong.

What I would probably do (starting from scratch) is clone the repository then create a local branch for your changes (git checkout -b my branch).

You make your changes in the local branch adding and committing files as above.

When you want to pull in upstream changes you can fetch/pull them, you can then either merge the changes into your branch (git merge origin master) or rebase your branch on top of master. Both achieve similar results in slightly different ways.

Return to “General discussion”