Adding an existing android studio project to gitlab repository - android

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.

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

Adding project to GitHub [duplicate]

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

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

Switching a branch type after commit

I have three branches, the main branch, the development branch and the new_feature branch.
The problem is I accidently set my first commit (initial commit)on the development branch.
Screenshot of my problem:
Full overview of my branches:
Question: How do I change it to the main branch?
As you haven’t merge remote branches (origin/development and origin/new_feature) into local repo. So there are two situations
Don’t need remote changes. Follow these steps:
Create a new “initial commit”. git checkout master, git checkout --orphan master1 and then git commit
Rebase development branch on it. git checkout development and git rebase master1 (if there has conflict file, you use to use git add filename and git rebase --continue).
Delete master and new_feature branch. git branch -D master and git branch -D new_feature
Rename branch. git branch -m master1 master, git checkout master and git branch new_feature
Force push to remote. git push -f --all
Need remote changes. Follow below steps:
Merge remote changes to local. git checkout development, git merge origin/development, git checkout new_feature, git merge origin/new_feature
Create a new “intial commit”. git checkout master, git checkout --orphan master1 and then git commit
Rebase development branch on it. git checkout developmen and git rebase master1
Rebase new_feature branch on it. git checkout new_feature and git rebase master1
Rename master branch. git branch -D master and git branch -m master1 master
Force push to remote. git push -f --all
You can merge your develop branch with your master branch or use the cherry-pick command from your master branch for retrieving your initial commit.
git push -u origin development//(push it up to development)
git checkout main //checkout local main branch
git pull origin development //Pull latest from remote development branch into main
git add -A
git commit -m "get latest from development"
git push -u origin //push up to main
You can rename your development branch.
$ git checkout development # checkout development
$ git checkout -b development-backup # backup development branch
$ git branch -D master # delete your current local master
$ git branch -m development master # rename development -> master
$ git checkout master # checkout master
$ git push -f origin master # force push, update remote master

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.

Categories

Resources