Git for my Remote Server for an Android Application - android

I'm running a remote Linode server - Debian 7.5 Profile (Latest 64 bit (3.16.5-x86_64-linode46))
A co-worker of mine already has an android application project locally on their machine.
I want to be able to transfer that project onto my server and adapt the git technology to it. So that it will enable me and the colleague to simultaneously work on the project.
How can I achieve this?
Are there any step by step tutorials on how to do this?
Thanks in advance

You might want to read this for using git on the server.
http://git-scm.com/book/en/v1/Git-on-the-Server
Tip. If you guys can use a shared folder (e.g., samba shared folder), just keep the common git repository there. Then you guys can clone it and push commits into the git not shared folder.
$ git clone samba_shared_folder_path
You can understand why it works after reading the above link.
Tip2, You can try the following at you local. (Just forget about 4-digit number)
a. make a local git repo and a commit
2037 mkdir common
2038 cd common/
2039 git init
2040 touch sample.txt
2041 git add sample.txt
2043 git commit -m "testing"
b. clone the commit.git into another folder
2044 cd ..
2045 git clone common my_common
2046 cd my_common/
2047 echo "new line" >> sample.txt
2048 git add sample.txt
2049 git commit -m "new commit from my_common"
c. push new commit from my_common(local) into common(remote)
2052 git push ../common HEAD:from_new_common
Just think about using a shared folder instead of common folder at your local.

Related

How to add one repository to another repository on Github?

How to add one repository to another repository on Github? I have one project workspace XXX and i have my own created repository YYY somewhere else, so i want to add that repo to that blank repo created.
Here is simple way I can think of
Clone the xxx repository
open it and delete .git folder
open terminal and type git init
type command git remote add origin GIT_URL_OF_YYY
add , commit and push
You could do this with simple two steps :
clone {current}
push {new}
A. clone {current} git clone
create local directory
open terminal
git clone ssh://john#example.com/path/to/my-project.git
cd my-project
B. push {new} git push <remote> <branch>
git remote add origin example.com/path/to/my-project.git
git push origin master
you may face an error of repo{s} timing, so.. you may need to fore pushing
and you may face some other problems then you will just run git add . git commit -m "first lanuch" git push -u origin master

Adding an existing android studio project to gitlab repository

I have a project in android studio that i want to commit to a gitlab repository. I have a link for this repository. What do i need to do, step for step, to add this project to said repository?
First you have to guarantee that this project is already a git repository on your local machine.
You can do this by checking if there's a folder .git in the directory. If there's none, do the following command:
# create a git repository on the current directory
git init
After that you need to make your repository point to gitlab
git remote add origin "url from gitlab"
Add files for your initial commit
git add -A
Commit the files
git commit -m "your initial commit message"
Push all the files to the remote(gitlab)
git push -u origin master
More information of each command can be found typing:
man git command
# example
man git push
For using gitlab when you have ssh keys and also your ssh key have passphrase, you have to follow instructions as follow (don’t forget to upload your public key to gitlab)(also you must use a private key which its format is openssh):
Have your project folder and its files.
Have Git Bash installed on your system.
Using git bash, go to your project directory.
git config --global user.name "your-name"
git config --global user.email "your-email-address"
git init
ssh-agent bash -c 'ssh-add “private-key-local-address”; git remote
add origin “online-repo-address”’ (will be asked for passphrase)
git add .
git commit -m “initial commit”
ssh-agent bash -c 'ssh-add “private-key-local-address”; git push
-u origin master' (will be asked for passphrase)
For further commits, you can commit changes in android studio and then repeat step 10 to push them to gitlab servers.

Cherry pick from local source

I am new to kernel building on android. I have a moto g. I used the cm source code and built a basic cm kernel. It booted. Now i want to cherrypick. I have cloned another repo. Now i want to cherry pick stuff into my kernel from that local source. I tried googling a lot but couldn't come up with a way. Can anyone help me?
Here I would like to share an idea to solve your problem.
Push the branch (where your stuff exists) from one repository to another where you want to cherry-pick your stuff.
For example, your stuff exists in kernel-1 repository on branch-1 branch and you want to cherry-pick your stuff into kernel-2 repository on branch-2 branch.
Go to kernel-1 repository.
$ cd $WORKSPACE/kernel-1
$ git checkout branch-1
$ git push $WORKSPACE/kernel-2 HEAD:refs/heads/branch-1
Now go to kernel-2 repository.
$ cd $WORKSPACE/kernel-2
And you will find branch-1 here. So you can cherry-pick your stuff.
I am assuming that you have two folder.
1. kernel (change will be cherry-picked into here)
2. optimus (change will be cherry-picked from here)
Go to optimus folder and craete a branch say, my-local-stuff from your stuff.
$ cd optimus
$ git checkout -b my-local-stuff <your stuff>
$ git push <absolute path of kernel folder> HEAD:refs/heads/my-local-stuff
Now go to kernel folder and you will find my-local-stuff branch.
$ cd kernel
$ git checkout my-local-stuff
$ git log
<you can see the commits which you have created into optimus folder>
Now cherry-pick the commit whatever you need into whichever branches.
Please let me know if more explanation is needed.

Automation of GIT repo sync, get older commit versions, verify version

I'm very new at GIT, apologize if this is a basic question however I couldn't seem to find a similar situation after searching google and stackoverflow. Here's my scenario:
I have a git folder with the latest commit version that I do NOT perform any commit (I won't do any changes in the code in my local directory). Other people performs the commit on their computer, I just need to get a specific commit version, copy it to a working directory and build code. I'm planning to make a program to automatically perform these steps in repeated cycle everyday. Steps summarized below:
Get the latest commit in repo_folder
Go back to old commit version
Copy to a work_folder
Then build code in work_folder
I'm not sure if these steps are the correct/best way to do it. Also, how can I perform #2 correctly and how to make sure my program have retrieved the correct commit version? Is #3 necessary? Or can I just build code directly in repo_folder (might modify some files after build), then afterwards perform git command to get the latest commit version again?
Here's my steps actual steps
1. Get the latest commit in repo_folder
repo init -u ssh://username#git.aaa.com:1234/manifest.git -b branch -m file.xml
repo sync
After getting to the latest repo, I search through the logs and perform git reset --hard
2. Go back to old commit version
cd .repo/manifests
COMMITHASH=git log --grep=$keyword | head -1 | cut -d' ' -f2
git reset --hard $COMMITHASH
cp file.xml new_file.xml
repo init -m new_file.xml
After this command, I'm not sure how to check if my current version is correct.
Steps 3 and 4 just simple copy and build commands not related to this question.
cp -r repo_folder/folder1 work_folder/folder1
cp -r repo_folder/folder2 work_folder/folder2
run build.bat
Just clone your local master to a new directory and then checkout to the version that you currently need in that one:
No copying, no mucking about.
git clone -l /path/to/master /path/to/working
cd /path/to/working
git checkout -f REV_OR_BRANCH_ID
If you have any generated files such as objects it is a good idea to clean them up - such as with make clean after a checkout.
from then on you can:
cd /path/to/working
git pull
git checkout -f REV_OR_BRANCH_ID

Ubuntu - How to commit a whole Android project to a local respository?

Being fairly new to Linux and very new to Git, this is proving to be.. problematic.
Can someone please direct me to or tell me the steps required (Ideally step by step) to do this?
I have a directory with my project in it, I want to commit that to Git, I know there is a .gitignore which ignores certain files etc. and I have used GitHub on Windows mainly for local respository stuff which is again the primary purpose now.
Any help on this would be greatly appreciated cheers!
Welcome to git and linux. Here are a few links to get you started
https://help.github.com/articles/set-up-git
http://git-scm.com/book
http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository
http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html
Git for beginners: The definitive practical guide
There are a couple of different ways to do this. The easiest in my opinion is the command line.
Open up a terminal, and cd to the directory that contains the android project.
cd /home/bob/foo
ls
Initialize the git repo, this will create a hidden .git file inside the folder
git init
ls -a
Create your first commit, by adding all files to the working tree
git add .
git commit -m "My First Commit"
You will now have a master branch, and 1 commit. You can veiw your commit with the following commands
git status
git log
If you aren't comfortable using the command line yet, you could alternatively accomplish all of this with a gui. Here are some programs for linux.
https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Graphical_Interfaces
You can do a simple
git init
in the command line (in the correct directory) to initialize your local repository. Then you just have to add your files and commit them :
git add .
git commit -m "first commit"
I strongly recommand you the read of the first chapters (at least) of the Pro Git free book to help you understand the basics.

Categories

Resources