GIT 101 - Newbie Friendly

Search This thread
V

Vatsal

Guest

DEVILOPS 007

Senior Member
May 24, 2016
3,866
1,668
Colchester
For building with the ROM source, you will need something more than just the patch.
Because each file is built from source while building a ROM unless you use prebuilts, which isn't possible in this case.

Thank you:)
I have the rom and I'm aware I can get the source from github by doing repo init commands etc and repo sync unless I'm wrong.
 
V

Vatsal

Guest
I have the rom and I'm aware I can get the source from github by doing repo init commands etc and repo sync unless I'm wrong.

So if I understand correctly, you want the patch to be built in the rom inline?

Do you know where you have to make the change in source? As far as I understand, you need to know that in order to make the patch built in rom.
 

nicesoni_ash

Senior Member
May 26, 2012
6,103
10,955
127.0.0.1
I have the rom and I'm aware I can get the source from github by doing repo init commands etc and repo sync unless I'm wrong.
Them get the repo, put the patch in frameworks/base and apply by

git apply patchname.patch

Or git am patchname.patch

If it'll show errors, which I am sure it will, go to that file where error is and fix it manually and then continue.

Sent from my "1+2" powered by Official RR 7.x.x
Compiled by myself
 
Last edited:

Arvind7352

Account currently disabled
Sep 26, 2014
934
1,415
GB
meettomy.site
No you can't because each android has a different api, so you can't use a kernel with api 21 or 22 on an api 24 or 25

Ah, no. Relation between Kernel and Android APIs are null.

Totally Core Android Specific. Kernel source may be patched (modified) in order to get the respective Android version booting. Differs for each Device.

Patches ? Where to find ? What patches to be applied ?
Don't know :p. Can be asked in any Kernel building guides (in Chef Central)

Programming knowledge in C/Assembly mandatory for working with the Kernel

Core Android refers to the modules (mostly coded in C/C++) which get Android up and Booting. GUI is based on Java, and that's where the role of APIs comes in.
 
Last edited:

HarshOne

Senior Member
Feb 20, 2017
52
3
Google Pixel 6
My device repositories are not available on github, But I got device tree and vendor blobs by making changes in similar device repo. That reference device's kernel's lineageos_defconfig is situated in htc msm8974 kernel repo. So how can I get lineageos_defconfig for my device, and which other my device related kernel files(.dtsi or any other) I have to push in htc msm8974 repo and get those files to make things ready for build?
Please help......
 
R

Raakib Zargar

Guest
Actually I flashed Resurrection Remix ROM on my Redmi 3s Prime and I miss the stock experience of stock apps of Mi Stock ROM like Gallery with hide option etc.
Then I tried to install the apps manually which didn't work.
Suggest a way please.
Answers are welcomed !!
 
Last edited:
S

sawdoctor

Guest
Actually I flashed Resurrection Remix ROM on my Redmi 3s Prime and I miss the stock experience of stock apps of Mi Stock ROM like Gallery with hide option etc.
Then I tried to install the apps manually which didn't work.
Suggest a way please.
Answers are welcomed !!

This isn't really the thread for this as it has nothing to do with git but most propriety apps like Miui or Samsung, HTC etc require their manufacturers framework to run. Unfortunately most Miui apps wont run on LOS/AOSP based roms
 

sscsps

Senior Member
Nov 17, 2013
616
189
delhi
Little mistake?

Now let's check if everything works
Code:
ssh -T git@gitlab.com

This warning...
Code:
The authenticity of host 'github.com (207.97.227.239)' can't be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Isn't the warning supposed to be for gitlab? Instead of GitHub? @Vatsal
 

Nis882

Member
Feb 6, 2017
21
0
Can anyone create a custom rom please!!!

I need a custom recovery for my device Micromax Q491 (Canvas amaze 4g), I dont know anything about this..
Can you please create a custom recovery for my device....
I would be thankful to you
 

chirag2474

Member
Mar 22, 2017
36
2
Please find my bootloader unlock code I am in trouble my phone is bricked and no recovery installed
Model - HUAWEI Y330-U11
IMEI - Mod Edit
S/N - A4S4C14A27031253


PLEASE
 
Last edited by a moderator:

post-mortem

Senior Member
Oct 4, 2012
2,156
775
Please find my bootloader unlock code I am in trouble my phone is bricked and no recovery installed
Model - HUAWEI Y330-U11
IMEI - Mod Edit
S/N - A4S4C14A27031253


PLEASE

This is the wrong thread for this type of question. Please do not ask the same question in multiple threads, it creates great confusion.

See the answer in another thread where you posted this question here.
 

DiamondJohn

Recognized Contributor
Aug 31, 2013
7,385
7,398
Sydney
I am using git for the most part to pull the latest changes for building ROMs for my device. To see changes I have made locally, I use
Code:
repo diff

What that does not show are any changes/commits that will be brought down if I do repo sync. I am guessing that the diff statement only shows the changes in respect to my current checkout, which will not be any new commits since the last checkout I did?

When I do a repo sync, I go for the following to ensure I get all the latest code.
Code:
repo forall -c git reset --hard;
repo forall -c git clean -fdx;
repo forall -c git checkout -f;
repo sync -fc --force-sync --force-broken  --no-clone-bundle;

Is there a way that without modifying any of my local changes, that I could actually do a diff with head (ie the latest commits)? ie preview the changes that will be brought with a repo sync?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    Great Help for Newbies

    Thanks Vatsal Sir _/|\_

    This will be very helpful for Newbies learning stuffs.

    Great Work :*

    -TechExhibeo
    5
    Hello,

    Today I would like to share an easy git tutorial for all of you. We at XDA believe everyone loving Android and passionate about the same can contribute something or other to the community. Not everyone is an expert at everything like theming, bootanimations, building ROMs, Kernels etc etc. But git is an essential yet powerful tool in most aspects. This thread is for new users and old alike , wanting a correct direction of learning basic Android by starting with git. Okay enough of lectures? Bwahaha I know it's boring lol

    So let's start

    Gitlab? What exactly it is? How is it different from github?
    GitLab is an application to code, test, and deploy code together. It provides Git repository management with fine grained access controls, code reviews, issue tracking, activity feeds, wikis, and continuous integration. Inshort and in simple english, it is a place to store all your sources, it maybe private, public or restricted.

    Difference : GitHub is a publicly available, free service which requires all code (unless you have a paid account) be made open.GitHub currently hosts the source code for tens of thousands of open source projects. GitLab is a github like service that organizations can use to provide internal management of git repositories.

    uc


    Signing up, Creating an account and setting up git
    Go to gitlab web
    uc

    You have an option to sign in with google, github, twitter or bitbucket. It's the easiest way. I prefer github:)

    Now let's download the git package. I use Linux Mint 18 so,
    Code:
    sudo apt-get install git
    Verify if it is correctly installed in your system
    uc
    .
    Now let's configure the terminal
    Code:
    git config --global user.name "Your Name Here"
    git config --global user.email "your_email@youremail.com"
    uc


    Now let's generate ssh keys
    go to your terminal and type
    Code:
    ssh-keygen
    and hit enter thrice I guess until you are back to bash.
    Or
    Code:
    ssh-keygen -t rsa -C "your_email@youremail.com"
    Now
    Code:
    cd .ssh
    cat id_rsa.pub
    (.pub is your public key while the other one is private key, Don't ever share private keys with anyone)

    Now let's verify all that we've done so far.
    Code:
    git config --global --list
    uc


    Now let's add ssh-keys we generated to our account at gitlabs OR we get this :p
    uc


    Click : Add an ssh key and copy paste the ssh-key (id_rsa.pub) there and click okay.

    Now let's check if everything works
    Code:
    ssh -T git@gitlab.com

    This warning...
    Code:
    The authenticity of host 'github.com (207.97.227.239)' can't be established.
    # RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    # Are you sure you want to continue connecting (yes/no)?

    Type YES and here we're done with configuration part :)




    XDA:DevDB Information
    GIT 101, Tool/Utility for the Samsung Galaxy Chat

    Contributors
    Vatsal, malybru, sawdoctor

    Version Information
    Status: Testing

    Created 2016-12-09
    Last Updated 2016-12-20


    XDA:DevDB Information
    GIT 101 - Newbie Friendly, ROM for the Android General

    Contributors
    The Arrow
    ROM OS Version: 2.3.x Gingerbread

    Version Information
    Status: Testing

    Created 2018-04-25
    Last Updated 2018-04-25
    5
    Wonderful Guide and great work @Vatsal ! This will help newbies a lot :) Every aspect of git is mentioned in 1 Guide :) Keep up the spirit sir! :)

    Cheers!
    jackeagle
    Forum Moderator
    3
    So now we learnt pull, push, status. We proceed with The most important command
    Code:
    cherry-pick
    {Most of the people might have heard of it, and wonder what it is?}
    Cherry picking in Git is designed to apply some commit from one branch into another branch, one repo into another

    Given one or more existing commits, apply the change each one introduces, recording a new commit for each. This requires your working tree to be clean (no modifications from the HEAD commit).

    When it is not obvious how to apply a change, the following happens:

    The current branch and HEAD pointer stay at the last commit successfully made.

    The CHERRY_PICK_HEAD ref is set to point at the commit that introduced the change that is difficult to apply.

    Paths in which the change applied cleanly are updated both in the index file and in your working tree.

    For conflicting paths, the index file records up to three versions, as described in the "TRUE MERGE" section of git-merge[1]. The working tree files will include a description of the conflict bracketed by the usual conflict markers <<<<<<< and >>>>>>>.

    No other modifications are made.


    So I would wish to cherry-pick a particular commit on the same repo we have been working upon.
    This is the commit I want to pick in my repo.

    uc


    For cherry-picking, first we need to learn
    Code:
    git fetch
    What does git fetch do?
    git fetch - Download objects and refs from another repository

    Command :
    Code:
    git fetch <URL> <Branch>
    Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated (see the description of <refspec> below for ways to control this behavior).

    By default, any tag that points into the histories being fetched is also fetched; the effect is to fetch tags that point at branches that you are interested in. This default behavior can be changed by using the --tags or --no-tags options or by configuring remote.<name>.tagOpt. By using a refspec that fetches tags explicitly, you can fetch tags that do not point into branches you are interested in as well.

    git fetch can fetch from either a single named repository or URL, or from several repositories at once if <group> is given and there is a remotes.<group> entry in the configuration file.

    When no remote is specified, by default the origin remote will be used, unless there’s an upstream branch configured for the current branch.


    So we fetch it from the AICP github with branch name n7.1

    and then we cherry-pick it by using
    Code:
    git cherry-pick <commit ID>

    uc


    and now it's cherry-picked. We have that commit in our repo.

    Note : This was an easy pick but most picks aren't this easy. We will learn about fixing conflicts later on

    Now we push it to gitlabs repo.
    uc


    and we'll check if our gitlabs repo has it now !?

    uc


    Now we learn how to create a new branch and push to that branch.
    We create a new branch by
    Code:
    git branch <new branch name>
    This creates a new branch with the new branch name specified in the command.

    Now we checkout the branch to switch to that particular branch.
    Command :
    Code:
    git checkout <branch name>


    git checkout <branch>
    To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.

    If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to

    Code:
    git checkout -b <branch> --track <remote>/<branch>

    You could omit <branch>, in which case the command degenerates to "check out the current branch", which is a glorified no-op with a rather expensive side-effects to show only the tracking information, if exists, for the current branch.


    uc


    Now that we have successfully cherry-picked,
    we will learn to show the commits logs in terminal itself (Not GUI).
    Code:
    git log
    can help us with that.
    We can also add a flag besides it for example 'git log -3' to see the last 3 commits.

    Shows the commit logs.

    The command takes options applicable to the git rev-list command to control what is shown and how, and options applicable to the git diff-* commands to control how the changes each commit introduces are shown.


    uc


    Now we learn how to revert a cherry-pick ?
    Well it's pretty easy.
    So I grab the commit ID from the commit I wish to revert.
    Here's the command
    Code:
    git revert <commit ID>
    uc

    After reverting make sure to push it to the repo to see the revert there as well :)

    Supposing we make a change to a repo and we don't wish to commit it. Instead we wish to reset the repo to the previous state,
    Here is a ways we can do it.
    Code:
    git stash
    It discards all the local changes and gets it back to the last commit.

    Also suppose if we want to revert 20 odd commits and we have force push access (And you are lazy like me :p), we don't revert it one by one. Instead we can just hard reset the repo to the last commit
    Command :
    Code:
    git reset --hard <commit ID>
    This is the easiest way to do it.

    Now the last one. Force pushing
    Sometimes github doesnt let us push after resetting hard because the previous commits dont exist in our repo.
    We can just force push to force it accept the commits
    Command :
    Code:
    git push -f <URL name> <branch name>
    It is basically a noob method to just add changes easily after a failed or unsuccessful push.
    3
    I will be available to answer in whatever capacity I can as well. There are many of you however that are far beyond my knowledge of git though :p

    I'm sure I'll be learning something