Hi.
Today I would like to show you how to use github. I'm not an expert (I'm rather n00b TBH ) but I learned some things and might help you with simple git commands.
1. Github? What's that?
In short it's the web-based hosting service for software development projects that use the Git revision control system. In English - the place where you store your sources.
NOTE: use the e-mail used in the website account creation
2.3 Create your unique SSH public key
Code:
ssh-keygen -t rsa -C "your_email@youremail.com"
# Creates a new ssh key using the provided email
# Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Now you need to enter a passphrase.
Code:
# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]
Which should give you something like this:
Code:
# Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.com
Now go to ~/.ssh folder and copy your id_rsa.pub content into account administration on github.com
... and check if everything works
Code:
ssh -T git@github.com
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)?
Duh?! Sure I want! Yes! Yes! Yessss!
Code:
# Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.
6. Merging the commits
Imagine the situation that you want to add a commits created by someone else. Let's use our great Recognized Developer nobodyAtall
You'll get a message to resolve the conflicts. In short and most n00b friendly way is to open pointed files and delete the:
<<<<<<<<
=======
>>>>>>>>
symbols.
And we're good
Now commit should be added. All you need now is to push - no need to commit
8. Changing the branch
While using git you may noticed that sometimes after fresh sync there is no branch selected. Imagine the situation when you are on a branch A and want to check to branch B, because it uses a different method (like framework patch etc.)
The solution is pretty simple.
Code:
git checkout -t remote_name/remote_branch
It allows you to change the branch to remote one without cloning the whole repo again.
If you feel that you have fixed a problem and want to help the developer to make his own ROM/kernel etc. you should consider to make a pull request. Pull request adds the changes you have made to the others repo.
First of all.
Fork and clone destined repo.
Check the previous post about forking and cloning.
Now make some changes and upload it to your own remote git.
Then, go to your forked repo using browser and click on Pull request.
Then choose the account and branch to pull-request.
Click and wait for your request to be merged
Merging a pull request.
Sometimes someone wants to add something to your code.
You'll be notified by e-mail and also see the notification on your github website.
Go there and click Open
When the changes can't be merged you'll see such message:
But when it's green, you are ready to merge it
Don't forget to review the code. In other way you'll be forced to delete the commit.
You can also use text method:
Code:
git checkout master
# Check out your master branch
git remote add TeamFun git://github.com/TeamFun/android_packages_apps_Settings.git
# Add a new remote named 'TeamFun'
git fetch TeamFun
# Pull in all the commits from the 'cameronmcefee' remote
git merge TeamFun/gingerbread
# Merge your master branch into the 'gingerbread' branch from the 'TeamFun' remote
git push git@github.com:eagleeyetom/android_packages_apps_Settings.git master
# Push your newly-merged branch back to GitHub
or
Code:
git checkout master
# Check out your master branch
$ curl http://github.com/octocat/Spoon-Knife/pull/25.patch | git am
# Grab the patch generated by a pull request and feed it into a new commit
$ git push git@github.com:eagleeyetom/android_packages_apps_Settings.git master
# Push your newly-updated commit back to GitHub
TIPS AND TRICKS
REVERT CHANGES
To discard all unstaged changes e.g. failed merge etc. type:
Code:
git checkout .
# to delete all changes
git checkout path/to/file
# to discard changes for a specific file
You can also use:
Code:
rm -rf ./
# deletes all of the files in the directory
git reset --hard
#This is going to restore the git to the previous state
HOW TO REMOVE COMMITTED CHANGES?
To remove committed changes you have to revert the commit. But how to do that? It's your answer
Code:
git reset HEAD --hard
HEAD is the previous commit. To revert to previous state use HEAD~1, HEAD~2 etc. you can also use the code taken from git log.
GIT PATCH AND GIT APPLY
Now I want to make a patch file to e.g. send an e-mail with my commited changes.
First I need to find a changes made by a commit. To do this I need to know commit ID.
Code:
git log --oneline #This would show the commit ID's
Now pick the commit for example 22a95d1 and use git show to make a patch
Code:
git show 22a95d1 > patchname.patch
And I got patch, but how to apply it?
The answer is easy. Use git apply.
Code:
git apply patchname.patch
# --check checks if the patch can be applied
FORCE PUSH
Sometimes github doesn't want to cooperate - just like some people
You can force it by adding --force or -f
Basing your experience on a kernel with how high bench mark score is as good as comparing how much fun you have in life with a 22" **** comapared to any other. Impressive number yes but also completely pointless. Such is the relation as to what you are implying.
Recovering iPad users may still remember the multitasking function where you can swipe left or right to … more
XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality. Are you a developer?