How to use git as a locale version control in android studio - android

We are an android developer team and we are doing our job on a single server using remote desktop. so everyone of our developers has a user account on the server and all are simultaneously developing using the android studio, we want to use git as version control but our repository must locate on that server not on git remote servers. how can we do that? we are already using Team Foundation Server but it has many problems so we want to switch to git.
any help would be appreciated.

Try using https://gitlab.com. It is free (Community Edition) and widely used.

If you know enough git to for use local repository /PC ( git init, git add, git commit , git checkout ) , you should not have much problem then. In your server you can prepare a git bare repository under any folder i.e. ( gitServer ) and create a remote on your local repository git remote ---. Now you sync up your local git with remote server easily through push, pull, fetch commands..
In case you need to understand git flow for 2-3 members of team, you can refer stackoverflow post How to use git correctly ?

gitlab is not proper for you if your group is small. It consumes a lot of memory and resources. I prefer Gogit https://github.com/gogits/gogs.

Thanks for all answers.
I used http://gitstack.com/
it is free for double teams.

Related

How to make project snapshots in android-studio

I am new to Android Studio and to Android Development as well. I am presently using version 1.3.1.
My question is how to efficiently make project "snapshots". - I am not absolutely sure the term of "snapshot" is good hence the quotes.
What I mean is to save the project as is at the moment and be able to make heavy changes without fearing to destroy what is already working well and also to be able to restart from this "snapshot" if it happens that the changes made break the project.
In other terms, how can I manage versions?
This can be achieved using a version control program such as git or svn, although git tends to be the industry standard tool.
You can follow a very simple online tutorial to get started quickly with the basics behind git. There are also a number of other excellent resources such as the git guide by Tower and the git book.
In regards to versioning, you can use git tag to tag specific versions (see docs)
#Create a new tag
git tag -a v1.0 -m 'Version 1.0'
#Create a new working branch 'version_2_dev' from v1.0
git checkout -b version_2_dev v1.0
You need to add the version control plug-ins like bitbucket, svn and git.

How to add Android-Project to GitHub [duplicate]

This question already has answers here:
How do you synchronise projects to GitHub with Android Studio?
(13 answers)
Closed 5 years ago.
I'm using Android Studio to code my apps. Now I want to work on 2 PC's and thought about using a Cloud-Service. I decided to use GitHub, but I can't find a way to synchronize my GitHub account with my Android Studio project...
Can anyone explain this to me ?
Best way to do this is probably through the good ol' command line. First, make sure you have git installed and in your path. You can get instructions from here.
Next, go to GitHub and create a new repository with a title and such. Instructions on that here. Don't worry about creating your first commit, we're going to do that on your local machine.
Now for the fun part.
Copy the repo link of your choice (I prefer ssh, but it depends on how far you went with the set up part) and head to the terminal.
cd ~/project-path-here
git init
git add .
git commit -am "initial commit"
git remote add origin <your link>
git push -u origin master
If all has gone well, you can reload the github page and see your new push.
On your other computer, you'll be able to clone down the repo you created.
cd ~/project-path-here
git clone <your link>
You can then use git pull and git push to retrieve and send changes to the server.
You can also look into Github's desktop application if you're on Windows or Mac for a simpler time, but I find these lack some more advanced features of git.
EDIT: To register your new git repo with Android Studio, Intellij, RubyMine, etc., go to the project settings (File->Settings), search for version control, and specify that your project is using git for version control. Here for more information on that. Once that is enabled, the VCS drop down will have more features. The ones to look at are Commit Changes (git commit and push) and Update Project (git pull).
Under the VCS tab in your Studio, there's on option to publish the project to Github. Will ask for your credentials, then you're good to go to push your code.
Just getting into Android app dev and I thought I might mention here that I think that we should gitignore the build folder. It's huge and it doesn't need to be repo'd
[Edit] I'm referring to the app/build folder. And hey I see it's not included in the Android Studio .gitignore

How to build a empty android git server?

I have a whole android project code,it is very different from google's,because a team have developed on it for one year.Now I decide to use git instead of svn.And I want to use repo script to maintain the project.How to transfer?I've try to mirror a git server from Google via
repo init -u https://android.googlesource.com/mirror/manifest --mirror
then build my branch,but when I merge my project code to it,it is too difficult.
Is there a easy way?Thanks!
I am working on this same issue, the most progress I have made is due to this google group discussion.
From what I can tell you are going to have to maintain projects individually using git (I think you can do a repo start instead of git branch to setup your branches, then when you are ready to push changes you can use git push to the mirror. The thing you can gain from the repo script is the ability to use repo sync to sync all of the projects, and repo start to make new branches.
Could you be more specific about the problem you ran into with the merge? I may be able to help more on that front.

What is Repo and Why does Google use it?

When I wanted to get Android source code, I knew that I have to use "repo". So what is repo? Why do they use repo and not just use GIT?, and is there a GUI for repo that enables me to pause/resume syncing, because every time I get disconnected occasionally it seems that repo starts syncing from the beginning!
As is mentioned in the android webpage, repo does not replace git. It is just a tool over git and helps you to manage multiple git repositories.
For example, suppose I have a big project which has a lot of features and I have several teams working on each feature and I created one repository for each feature. For example suppose my repositories are wifi, telephony, power management, etc. This action has sense when your features have different life cycles. For example if I won't touch the wifi feature in my next release and but I will modify all the rest. So under this scenario, my project or product is distributed in several different git repositories.
So, to get a centralized photo of my project (one specific moment of my project, for example a milestone), I need to get the revision (git hash or tag) of each repository. Remember that we have one repository for each feature. Manually I could do it but could be very painful. So, with repo you can have one MANIFEST which links to all the revisions of each git repo (one for each feature) and have an specific picture of my whole project.
Simply, I could say that is a way to manage centralized multiple git repositories which are decentralized.
With repo you have more features, not only to checkout at a specific point. For more info go to http://source.android.com/source/using-repo.html.
Repo and git - what they are, what they are for - is explained on source.android.com
To work with the Android code, you
will need to use both Git and Repo.
Git is an open-source version-control system designed to
handle very large projects that are
distributed over multiple
repositories. In the context of
Android, we use Git for local
operations such as local branching,
commits, diffs, and edits.
Repo is a tool that we built on top of Git. Repo helps us manage the
many Git repositories, does the
uploads to our revision control
system, and automates parts of the
Android development workflow. Repo is
not meant to replace Git, only to make
it easier to work with Git in the
context of Android. The repo command
is an executable Python script that
you can put anywhere in your path.
There's no GUI for Repo, as far as I can tell, but there's quite a bit of guidance on the site above for controlling what Repo is doing from the command line.
Concerning the pause and restart point, whilst in a terminal window doing a repo sync you can hit, "ctrl + z" to pause the repo sync. To restart simply type "fg" into the same window.
Go to:
http://source.android.com/source/git-repo.html
and you can download the repo script. It is a Python script that uses the git command to do distributed source code revision.
After you have executed repo sync, do a ps -auwf to see the processes:
For mine I saw:
\_ python -E /sde3/root/download/android/android/.repo/repo/main.py --rep
\_ git fetch korg
\_ git fetch korg
\_ git index-pack --stdin -v --fix-thin --keep=fetch-pack 5227 on
Yes, repo sync breaks often. But it is robust, just restart the command and it will resuming syncing again - those that have been updated will not be re-applied, so it will skip over them and continue with the rest.
repo sync has various useful options:
-f recovers from disconnects
-c just uploads the branch you asked for
-j <#CPUS> speeds up the sync by increasing the number of cpus used by the command

How to use Git on Android?

I have a desktop application using git for synchronization. I have also an android application which do the same as the desktop, but I don't know how to do the synchronization part on it. I haven't found any implementation of git on android. I found a jgit, but its unwell documented and I was not able to do even a commit with that.
I was thinking about remote commands to my git server from my android app, but this is really a tease for me.
Could you tell me if any other git implementation which can be used on android exists? If you have any idea how to solve that, please tell me.
Since this question was first posted, an Android app has been added to the market that can checkout Git repos, called Agit. It can't commit or push yet, but the clone/fetch/pull functionality is useful. The other issue is that a patched version of ConnectBot needs to be installed before Agit if you want to use SSH keys. If you already have ConnectBot, uninstall it first. I did not do this and ran into problems.
Edit: As of April 2021, the ability to push and pull has been added, however, it does seem to be very buggy as I have only been able to pull changes, but never push them.
Another option is using ASE. There seems to be a full-featured pure python implementation of git at https://github.com/jelmer/dulwich.
You can install https://github.com/termux/termux-app # https://play.google.com/store/apps/details?id=com.termux, then you just need to open the terminal and type:
apt update
apt install git
If the device is rooted, you can also use debian's debootstrap ( http://wiki.debian.org/Debootstrap ) application to create a debian/armel image, mount it in your android device and chroot to it, you have aptitude here so any package available for armel can be installed on your device (to install git: aptitude install git). Look here for information on how to install debian for your android: http://lanrat.com/install-debian-on-android/
Some other solutions that are now available, besided Agit, since this question was last answered:
A git & mercurial client for bitbucket called Bitbeaker
A git app from github
The Android Java IDE AIDE also has git functionality, so you can download from a git directory and if its an Android app modify and run it aswell.
You can also try Pocket Git: https://play.google.com/store/apps/details?id=com.aor.pocketgit
Pocket Git supports SSH (with passphrases, but private keys seem to have some issues) and HTTP, cloning, stage, unstage, commit, push and pull; create, delete and merge branches; and it also has a graphical log viewer and can show diffs.
Disclaimer: I'm the developer
A lot of already existing apps have been posted in the answers, but following links might be useful for those looking for their own implementation:
libgit2
This is a pure C implementation that claims to be highly portable. And the project also describes how to compile the sources for android platform. Now what needs to be done is to write a JNI binding for it. Even an executable binary would be sufficient in some cases.
HTTP (dumb) protocol
As an alternative, if one's purely interested in read operations from a repository, this protocol can be implemented over HTTP. There is also a smart protocol which depends on ssh and does differential transfers.
JGit Core Sources
Using just the core package from its sources. All the javax.* dependencies and other incompatible/alien classes will needed to be replaced with android alternatives though. But worth the effort if a pure Java implementation can be ported to android.
I would suggest to take a look at Gidder. It's Git server implementation for Android with user and repository management and also support dynamic DNS. You can easily store your code in your Android device and access using a WiFi connection.
MGit is the successor of SGit, and it works very well for me.
Update:
Comment underneath this answer by OP- (Nathan Osman)
unfortunately, I was forced to pull the application after some recent policy changes on the Play Store that required publishers to have their address displayed on the application's store page.
Original Answer
I've just (circa April 2013) published an app on the Play store named GitDroid. The application allows you to do the following:
clone remote repositories
pull from the remote and merge new revisions
view commits and browse files
The app cannot push to a remote or make local commits yet - this is planned for a future update.
This is how I would do it:
Well you likely want to define an interface for your synchronization needs.
You implement this interface in C for both desktop and android device (with the help of the NDK) by making the implementation use git (native).
Then, for the Android app, you code a JNI layer on top so that it exposes the interface to Java.
The tricky part would be to have the different git commands compile for Android: you'll have to rewrite makefiles.
Try SGit, it can commit & push over SSH with pssphrase-less keys and it is available on F-Droid. It is built on top of JGit. It is not perfect (yet) and JGit implementation is not as good as original Git, but looks usable.
You can install git on android with Termux. Just install from Play Store and run the command:
pkg install git
Reference: https://mvprepublic.com/blog/2020/04/08/how-to-run-git-on-android-devices/
Update: CubeGit has been removed because of changes inside the Android system and missing time / incentives to update.
Please pick one of the alternatives.
One more option is was CubeGit.
We have released CubeGit on Google Play a few days ago.
It is an interface to a cross compiled git binary and also supports local commits and push via ssh/http/https.
JGit - http://eclipse.org/jgit/

Categories

Resources