Adding project to GitHub [duplicate] - android

This question already has answers here:
How do I add files and folders into GitHub repos?
(12 answers)
Closed 2 years ago.
I have 2 Android App projects that I want to add to the same GitHub repo. I wish to create 2 folders in the repo and upload the app files to the corresponding folders. Any way that I can do it using Git CLI and Git Bash rather than uploading the files manually?

First of all,create a new repository from the github.
Then copy the repository ssh url or https url for the repository.
After that cd to the main directory such that the two sub folders are inside it
Then type the following in the terminal -
git init
git commit -m "first commit"
git remote add origin [url-for-github-repo]
git push -u origin master
If Your github url is git#github.com:AnishAralikatti/Android.git
git init
git commit -m "first commit"
git remote add origin git#github.com:AnishAralikatti/Android.git
git push -u origin master

Related

How to link a project to private git hub repo?

I am currently using flutter in Android studio and was wondering how to link a project to a private repo in android studio?
Btw this is a condensed self answer to myself.
cd <project folder>
git init
git add .
git remote add origin https://github.com/USERNAME/project.git
git fetch origin
git commit -m "My first commit"
git push -u origin master
Then in android studio
VCS -> Git -> Push

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.

Git for my Remote Server for an Android Application

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.

Downloading Android source with repo

When I give these commands then the 2.3.7 branch gets initialized in current directory and source gets downloaded.
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
repo sync
Thereafter if I give following command what exactly happens
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
or
repo init -u https://android.googlesource.com/platform/manifest
My Questions
Will my earlier branch be deleted which I have downloaded with great difficulty? Cant I have multiple branches existing simultaneously?
If I can have more than one branch then how to access them? I dont see any directory called 2.3.7 or 4.0.1.
The repo directory structure is very confusing. Can anybody guide?
You should start a new repo branch within the same source code branch
repo start BRANCH_NAME [PROJECT_LIST]
Also refer to the following book on how to switch and make use to features in git
Look at section on branching and merging. Create branch using repo and then git commands to move around
You should do a repo init in a different directory. repo init clones the git structure specified by the manifest file
e.g
android/gingerbread/repo init
android/eclair/repo init
I see that you want to sync a new branch while using the files downloaded at previous sync to save download time.
create a new directory
copy the .repo file (hidden) from the old branch_folder (gingerbread in your case) to a new directory
cd into that directory
Finally you can do:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
repo sync

Categories

Resources