Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 238
Jurgen van Delft Avatar asked Apr 23 '16 18:04

Jurgen van Delft


2 Answers

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
like image 145
Eduardo Seabra Avatar answered Oct 13 '22 00:10

Eduardo Seabra


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):

  1. Have your project folder and its files.
  2. Have Git Bash installed on your system.
  3. Using git bash, go to your project directory.
  4. git config --global user.name "your-name"
  5. git config --global user.email "your-email-address"
  6. git init
  7. ssh-agent bash -c 'ssh-add “private-key-local-address”; git remote add origin “online-repo-address”’ (will be asked for passphrase)
  8. git add .
  9. git commit -m “initial commit”
  10. 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.

like image 44
Peyman Mahdavi Avatar answered Oct 13 '22 00:10

Peyman Mahdavi