9

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?

2 Answers 2

13

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
Sign up to request clarification or add additional context in comments.

1 Comment

will these commands point to the folder which has my project?
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.