I have an issue with Android Studio. Once I enabled Git in my IDE it's always turned on even when i'm creating new project. After creating new project it's just automatically merging with my last created repository. But when i saw some tutorials people always enable them after creating a new project. How can i make this working like that? Or it's normal that my Git always enabled?
It sounds like you are creating the new project in a folder that already has a git repository. If you have a folder projects, you should create projects/app1 and projects/app2 each with their own git repo. Don't create a git repo in projects itself.
To find out if a folder has a git repo already, you should start Git Bash (on Windows) or Terminal (on Mac/Linux). Then cd to the folder and then type ls -a. If you see a subfolder named .git, then that folder has a git repo.
Since you are just beginning, you can probably just delete the .git folder and start over.
WARNING: Deleting .git will remove all history of commits. Do not do this if you have an on-going project that contains commits.
Related
I create a new repository in bitbucket and create new android project want to add in a new repository but whenever I do the old android bitbucket project added to new repository along with the new Android project, I want only one project with one repository, I tried all nothing is working, I have also changed URL from git bash but whenever I add, commit and push project from android studio, it shows old project hierarchy in push window and it pushes to new repository. I don't want to add an old project with a new repository. I tried many command rehead,rebash etc etc..any help will be appreciated
From the comments:
Parent directory has common git directory
That's the problem. You need to create your new project in a directory that does not already have a .git directory. This .git directory stores all of the information for a repository. Each repo must have an independent .git directory. So create a new Android Studio project in a different folder. Then cd to that directory and run git init from the command line.
I have encountered a similar problem and found that the best solution is as follows:
1-Create the repo on the bitbucket.
2-Upload your android project to bitbucket using git extensions (very nice program to dealing with any git host).
3-Now open the project using android studio and it will be automatically set with the VCS
and now you could easily push and pull and do any git stuff from inside android studio
This may help with Bitbucket. If you create a new repository that includes any templates, it may be problematic in Android Studio if you're less familiar with git. Be sure to select "No" for option "Include a README?". Here's what it looks like at the time of this post:
in the past, I did not download the telegram source with the git but now i need update my source and I need connect myProject (my Unofficial Telegram), to mainProject (Telegram) on github. my IDE is Android Studio. git in Android Studio is in VCS menu. but I do not know what to do, for conect my project to github project.
Make sure you have git installed on your system. If not, go to this link and download it
https://git-scm.com/download/win
Right click inside your local project folder and select 'Git Bash Here'
(If you want to clone your entire GitHub project into your local project, do it by typing:
git clone https://github.com/DrKLO/Telegram.git
If you already have the files and you just want to update it, skip this cloning step)
Check if your project folder has .git folder in it. (Check the hidden folders too) If there isn't one, type the following in your GitBash window
git init
Add the link to your GitHub (remote origin) by typing
git remote add origin https://github.com/DrKLO/Telegram.git
Update your files with the GitHub source by typing
git pull origin master
If you just want to know how to connect your project in Android Studio to GitHub, here's a simple tutorial:
https://www.londonappdeveloper.com/how-to-use-git-hub-with-android-studio/
(Skip the steps where he creates a new GitHub repository and an Android Studio project, since you already have both)
For detailed understanding on using git and github, i suggest you take this course:
https://in.udacity.com/course/how-to-use-git-and-github--ud775
invalid root mapping androd
i have download a project from github and open it in Android Studio it showing following error see image..
Check weather in the folder there is an hidden folder named .git that is supposed to contain the git information. If it's not there that is the problem.
Anyway other then that you could probably try to save as backup the current directory and clone it again in a new folder so that you can check if everything is the same.
If you have git in your shell (and I suppose you do since you are on linux) it's really easy, just try something like:
git clone repo_url
Says that the project android studio go configurations are incompatible. Either try to use the project with the git clone option, or delete the hidden .git extension.
The error happens because Android Studio found a remnant of git (something like .gitignore) in the project directory but not found any .git folder in the project. So it complaining that the project is supposed having a .git and giving an optional to create and set the root directory as a project with git. Other then that, you can work with the project without any problems.
When you downloading the project from the github via clone or download -> download ZIP, you will losing all the git files of the project. So you losing all the history of the project which is in the git. Instead download ZIP, you can clone the project with:
git clone remote_project_file
When you clone your project from git make sure you do (forgetting the recursive flag usually causes the vcs root mapping problem):
git clone --recursive YOUR-GIT-URL
or if you have already cloned then to fix it:
git submodule init
git submodule update
I had an old Android project that I think I had started in Eclipse or some old version of Android Studio. Anyway the project structure was completely different from how Android Studio organizes things now with Gradle. Rather than try to update every file location I just started over with a new project using the same name.
Now I would like to update my GitHub repository but I don't want to lose my previous commits, which doing something like git push --force origin master would apparently cause (see here and here).
This question is similar to Replace GitHub repo while preserving issues, wiki, etc, but I would like to know for the specific case of Android Studio. Also the current answer to that question does not preserve the commit history.
I am going to try to figure out a way to do this based on hints from here and here. If I can solve it, I will post my answer below.
Rename your current project folder (the new one you want to put on GitHub) to something like MyProjectBackup.
In Android Studio, go to File > New > Project from Version Control > Git. Then log in with your GitHub username and password and select your old project's repository name from the list of your GitHub repos. Continue through the import wizard and you should end up with your old project in Android Studio. (Now, for example, your old project is in MyProject and your new project is in MyProjectBackup).
Manually delete everything except for .git and .gitignore (and maybe the readme and license) from your MyProject project folder. (I had tried git rm -r * but I was getting errors.)
From the command line in your MyProject folder run
git add -u
git commit -m "deleting old files before adding updated project"
This will update the tracked files in the working tree for all the manual deletions you just made.
Copy in all your new files from MyProjectBackup. Then run
git add .
git commit -m "new updated project"
git push
Now your new project will be in GitHub and the old project's commit history will still be available.
Helpful reading
Git Basics - Recording Changes to the Repository
I am developing my Android app on Eclipse. It works fine and run properly. But, I want to migrate to Android-Studio. Here is what I am doing:
Create a repo in GitHub with .gitignore, a README.md and LICENSE files
From within my project folder run the following commands:
git init
git add .
git pull git-url master
git init (again)
git add . (again)
git commit -m "First commit"
git remote add origin git-url
git push -u origin master
From Android-Studio, I checkout the project from Git
Run the app from Android-Studio (after alot of configrations)
My concern is that ALL my project files and folders are pushed to the remote repo at GitHub, including for example: bin\ and .settings\ folders. Meanwhile, I only need to push the important and platform independenet files because I work in both windows/mac systems and in differnet locations (hence, this is the reason behind using version-control).
My questions are:
How to pull the files on GitHub first, and then use .gitignore to push the "important and platform independenet" files from my project folder into GiHub
What is the recommended method to export a project from Eclipse to Android-Studio while using GitHub ?! should I:
checkout the project from Git (as I am doing now) ?
use Eclipse Export Tool ?
or clone the project first into a directoty and then loaded into Android-Studio as an existing project ?
You can pull your files by git pull origin master command from GitHub.
Add the name of the directory/file in .gitignore file you don't want to push. see more
You can clone the project first into a directory then load it in Android-Studio.