I've set up a Git server on my LAN (Simple Git Server for Mac). I'm using other machines on the LAN for Android Studio development. What now? On Android Studio's VCS menu, "Integrate Project..." is grayed out.
If I understand, I have to first create a local repository on the workstations, then somehow get my project files into it and get it copied to the server. Can't figure out how to do either. It seems usable if you already have your remote repository set up and populated, but I can't get to square one.
Also: is it recommended to have a separate repository for each project?
If you already have a git repository set up online. First you do git init in the directory that you want to submit to git, then you need to commit the files you want to add by doing git add . for all your files or git add <your file> for a specific file. After that you need to commit the files by doing git commit -m "your message here " and then you do:
git remote add origin <remote repository URL> //get this from git assuming your have already set up the git repo
# Sets the new remote
git remote -v
# Verifies the new remote URL
Push the changes in your local repository to GitHub.
git push -u origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin
All this info comes from the git documentation here:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
And yes, typically you want to have a separate repository for each project. There are exceptions, but personally, I have yet to find a suitable one.
Related
This question already has answers here:
Why did my Git repo enter a detached HEAD state?
(15 answers)
Closed 2 years ago.
Being new to git and gitlab, instead of cloning the repository i downloaded it,fixed bugs in it over 100+ files have changed, now i want to push it to gitlab.
I have tried
-Cloning the repository...then pasting all the contents of the downloaded repo and commiting, didn't work.
it says detached head.
Is there any way to show all my changes on the cloned library and successfully push it.
Navigate to your project directory using cd command then,
- git init
- git remote add origin <repo_url> # copy from your repository, either SSH or HTTPS (Note: SSH requires SSH keys to be added for your device)
After this, you can follow your usual git commands like,
- git add . # add all project files
- git commit -m <commit_message> # commit the latest changes
- git push # push changes to the remote repository
Note: Confirm your .gitignore file before committing any changes
I can't find instructions for how to copy an Android Studio project from my Mac to a remote Git (NOT GitHub) server.
This doesn't seem like it should be hard but I have searched for hours and can't find anything specific.
A step-by-step guide would be wonderful.
The steps below works for any Jetbrains based platforms like Intellij IDEA, Android studio, PHPStorm, etc. It also works for any git platform (including GitHub)
You can use the following steps to push your code to a remote Git repository:
Goto VCS in the menu bar.
select "Enable version control integration."
choose "Git"(not GitHub) and press ok.
Then you can see a Version control tab near android monitor.
Open version control tab, go to local changes, and add all unversioned files to VCS. (Either right click on unversioned files and click add all, or click browse, select all, and click plus sign to add all to VCS)
Commit changes (Ctrl+K)
Push changes. (Ctrl+Shift+K)
define remote URL
enter username and password.
click on push.
To copy android studio project to a remote repo, you just need to follow below few steps (for your situation):
If the android project already managed in a local git repo
In Android studio Terminal windows, use below commands:
git remote add upstream <URL for the remote repo> -f
git push upstream master
If the android project is not manage in git repo for now, you can use below steps:
In the root directory of your project, execute the following commands,
git init
git remote add origin <URL for the remote repo> -f
touch .gitignore
#Add the (pattern of) files you do not want to traced by git, as https://github.com/github/gitignore/blob/master/Android.gitignore
git add .
git commit -m 'add .gitignore'
git push origin master
Note: If the remote git repo is not empty, you can clone the remote repo locally and then copy your project in it. Then commit and push.
I register on git web site and create a project named Book.this was repo addresshttps://xxxxxxx#gitlab.com/xxxxxxx/Book.git/
and on android studio I pushed my project to git. for a reason, I deleted this project from git site not android studio.now I create another project with this repo:https://xxxx#gitlab.com/xxxxxx/Thread.git but when I am pushing my project I got this error:
manifest#manifest-System:~/AndroidStudioProjects/Book-ThreadExample$ git push -u origin master
Password for 'https://xxxxxx#gitlab.com':
remote: Not Found
fatal: repository 'https://xxxxxx#gitlab.com/xxxxxx/Book.git/' not found
Actually Book.git has been deleted before .how can I change repo? or solve the problem?
I use this command for add remote but I got another error:
git remote add origin https://xxxxxx#gitlab.com/xxxxx/Thread.git
fatal: remote origin already exists.
I am using git on android studio.
I solved my problem.
The error "remote origin already exists" means what it says: I am trying to add a remote with the same name as one that already exists. I need to either delete it first with git remote rm origin, or use git remote set-url to change the URL of the existing remote.
I have downloaded the current master of Android AOSP which is Android 6.0 source code.
Is there a way available using repo to set the master to Android 5.1 so that all git repositories are set accordingly?
Note: I wish to do this without downloading again.
Quoting from source.android.com:
To check out a branch other than "master", specify it with -b. For a
list of branches, see Source Code Tags and Builds.
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
Edit
Note: I wish to do this without downloading again.
You can try with:
repo init -b <manifest-branch>
repo sync -j8
Edit 2
I want to know if there is way to do it without downloading. The sync
would download from google servers.
The documentation is really clear about the sync command:
Downloads new changes and updates the working files in your local
environment. If you run repo sync without any arguments, it will
synchronize the files for all the projects.
When you run repo sync, this is what happens:
If the project has never been synchronized, then repo sync is equivalent to git clone. All branches in the remote repository are
copied to the local project directory.
If the project has already been synchronized once, then repo sync is equivalent to:
git remote update
git rebase origin/<BRANCH>
where is the currently checked-out branch in the local
project directory. If the local branch is not tracking a branch in the
remote repository, then no synchronization will occur for the project.
If the git rebase operation results in merge conflicts, you will need to use the normal Git commands (for example, git rebase
--continue) to resolve the conflicts.
Since you already synchronized the project once the sync command is equivalent to a rebase.
I downloaded the android code from source.android.com. Then I created a new branch from this code:
repo start mybranch platform/external/webkit
Then I tried to switch to the new branch using :
git checkout mybranch
which failed with this error message:
fatal: Not a git repository (or any parent up to mount parent /media)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
set).
I tried the steps mentioned in the android link.
One more problem: when I use the command
repo branch
it shows only the branch which I created eailer. How can I switch between the code I have downloaded and the code I have made changes to?
The android source consists of several hundred git repositories. The repo tool helps maintain all these repositories.
Therefore when you are directly in the root of your android clone, you are not actually in a git repository. You have to enter a sub-directory containing a git repository before you can start using git commands.
For example the build/ directory is a git repository itself, you can try:
$ cd build/
$ git checkout mybranch
Which sub-directory you need to enter of cause depends on where you want to modify the android source. :)