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:
Related
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.
I am working on an Android Studio project and I would like to add a getup repository to the current project. I am using a Mac.
I have downloaded the Github repository and unzipped the folder and was able to create a NEW project using the GitHub repository in Android Studio, but I do not know how to either
A) merge the two projects in Android Studio so my initial project can use the new GitHub Repository Project.
or
B) if I did this process incorrectly and I need to add the GitHub repository directly to my initial Project. I just don't know how and I have looked everywhere for the answer. Any assistance would be fantastic.
I found this answer about merging projects, but I do not know where to find my projects "module root"
You may refer to these 2 links, 1 and 2 for elaborations.
First of all, open the project you want to push in Android Studio.
Click VCS -> Enable version Control Integration -> Git
There doesn't seem to be a way to add a remote through the GUI. So open Git Bash in the root of the project and do git remote add
Now when you do VCS -> Commit changes -> Commit & Push you should see your remote and everything should work through the GUI.
If you are getting the error: fatal: remote already exists that means you already added it. To see your remotes do git remote -v and git remote rm to remove.
You may also refer to here and here for more understanding.
I want to versionate an Android project with git but I am wondering what is mandatory to add to git repository.
I know about .gitignore file and I also have read this question: What should be in my .gitignore for an Android Studio project? but I have seen that there are a lot of different opinions about what should I add or remove from .gitignore file.
My question is not so open, I just want to know what is mandatory add to git repository, I mean that if I create a new project, versionate it and clone that repo in another computer, the project will work without problems.
Just the needed files I need to make my Android git project works in other computer when I clone my git repository. I am using Android Studio.
So, what files are mandatory to versionate on Android git project?
There is a great github project that includes gitignore files for every kind of project.
There is one for Android.
https://github.com/github/gitignore/blob/master/Android.gitignore
I always use this for my projects.
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
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