Upload AndroidStudio project on GitHub as a collaborator - android-studio

i'm having a trouble with AndroidStudio and GitHub: I need to upload a project on a GitHub repository of which I'm collaborator. How can I do it? I know how to upload a project in a new repository but i don't know how to do that on a repository that's not mine. (I have commit rights). Thanks to everyone

git init
git remote add origin https://github.com/username/repository.git
git add .
git commit -m "first - commit"
git push -u origin master

Related

How to recover from forgetting `repo start`?

If I'm working on an Android change and I git commit but forget to repo start first, how do I recover from this so that I can repo upload my change?
To retroactively repo start new-branch-name:
git checkout -b new-branch-name
git branch --set-upstream-to aosp/master
repo upload .

Can't push local project to gitlab

i'm trying to push a local project to a gitlab repository. I followed the usual commands provided with each new Project. Everything worked just fine until the last command; I acctually dicovered the local project is being pushed to a gitlab project that I actually deleted.
And each time I create a new project and try to push to it, the files are directed to the one I deleted but is somehow re-created with every push.
Any thoughts?
Try reading the following guide. Although is for github, is almost identical for gitlab. (understanding git is the key). I think you need to re-formulate your question better:
You have the following remote: origin with path https://<your-gitlab-project-repo-path>.git. Then locally, you run:
cd your-project
git init .
git remote add origin https://<your-gitlab-project-repo-path>.git
git add .
git commit -m "initial commit"
git push origin master
Done.

git push --mirror - internal server error

I have created a git repo using (GIT API) and initiated it with git init. (but no git add or git commit command) . when i try to use the git push --mirror , it gives internal server error.
I saw the following bug (100+ ref will give internal server error)
https://github.com/isaacs/github/issues/1253
even my repo got 500+ refs.
Do i need to use git add and git commit to push the repository to github with mirror command ?
when i do the git add and git commit on local repo, i can push the content.
I'm doing all those using the API, and is it possible to use git push --mirror without any git commit or git add commands?
When i go to the remote repo, i can see the GitHub quick setup page, asked to execute git add, commit etc...
my questions is how should i avoid that GitHub quick setup page,and push my contents to the remote repo without executing git add, or git commit ?
I don't understand what's your content.
If you have file and don't add them and don't commit, you have no content, as far as git is concerned.
You need to have at least a commit to push your repository, otherwise you're pushing nothing.

Push a newly created file into git repository

I have created a git repository of a linux directory and pushed all files into it. I have recently moved a new file into that linux directory and now want to push this new file into its git repository. I am trying to do so by typing
git push origin master
in the command line but I am getting the errors:
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Does anyone know how to push a new file into an existing git repo of the folder in which the file is present? I am new to git so would appreciate suggestions.
If your file is already in the git repo you have created, adding and committing are enough: no need to push.
myrepo <== "I have created a git repository of a linux directory"
.git (the .git folder is the git repo referential)
myNewfile <== "I have recently moved a new file into that linux directory"
Ie. there is no remote 'origin' to push to for a local git repo.
The chapter "Git Basics - Recording Changes to the Repository" is the good place to start.
git add myNewFile
git commit -m "Add a new file"
Validate if you have the repository branch (on which you are working) checkedout.
Make sure you pull the updates first
Do 'git add newfileNameWithPath' and commit before you push it.
It seems you have a wrong understanding about git push command, please read the following figure, which will give you a more clean concept.

Git - Syncing a Github repo with a local one?

First off, forgive me if this is a duplicate question. I don't know anything but the basic terminology, and it's difficult to find an answer just using laymen's terms.
I made a project, and I made a repository on Github. I've been able to work with that and upload stuff to it for some time, on Windows. The Github Windows application is nice, but I wish there was a GUI for the Linux git.
I want to be able to download the source for this project, and be able to edit it on my Linux machine, and be able to do git commit -m 'durrhurr' and have it upload it to the master repository.
Forgive me if you've already done most of this:
The first step is to set up your ssh keys if you are trying to go through ssh, if you are going through https you can skip this step. Detailed instructions are provided at https://help.github.com/articles/generating-ssh-keys
The next step is to make a local clone of the repository. Using the command line it will be git clone <url> The url you should be able to find on your github page.
After that you should be able to commit and push over the command line using git commit -am "commit message" and git push
You can use SmartGit for a GUI for git on Linux: http://www.syntevo.com/smartgit/index.html
But learning git first on the command line is generally a good idea:
Below are some basic examples assuming you are only working from the master branch:
Example for starting a local repo based on what you have from github:
git clone https://github.com/sampson-chen/sack.git
To see the status of the repo, do:
git status
Example for syncing your local repo to more recent changes on github:
git pull
Example for adding new or modified files to a "stage" for commit
git add /path/file1 /path/file2
Think of the stage as the files that you explicitly tell git to keep track of for revision control. git will see the all the files in the repo (and changes to tracked files), but it will only do work on the files that you add to a stage to be committed.
Example for committing the files in your "stage"
git commit
Example for pushing your local repo (whatever you have committed to your local repo) to github
git push
What you need to do is clone your git repository. From terminal cd to the directory you want the project in and do
git clone https://github.com/[username]/[repository].git
Remember not to use sudo as you will mess up the remote permissions.
You then need to commit any changes locally, i.e your git commit -m and then you can do.
git push
This will update the remote repository.
Lastly if you need to update your local project cd to the required directory and then:
git pull
To start working on the project in linux, clone the repo to linux machine. Add the ssh public key to github. Add your username and email to git-config.
For GUI you can use gitg.
PS : Get used to git cli, It is worth to spend time on it.

Resources