Remove old and add new git in android studio - android

I have tried to configure android studio with git and messed up.
How to completely remove old git that I could create new one?

In order to drop the current git repository and create a new one you need to:
Go to the project's directory: cd PROJECT_DIRECTORY
Remove all the git specific files: rm -rf $(find . -name ".git*")
Initialize a new git repository: git init
This doesn't remove your project's files, only git configs

You can remove GIT from your Android Studio Project in File → Settings → Version Control → In VCS select and Apply.
Then you can add it back in VSC Menu → Enable Version Control Integration → Select GIT → OK button.

Just a simple way
Open the terminal in android studio.
git remote set-url origin <NEW GIT URL>
now the project url is changed from old link to new one.
Then you can use >
git init
and upload your files.
Happy coding :)

Delete the .git folder & .gitignore and start again.
Google for how to display hidden folders on windows to see the .git folder.

In Android Studio terminal in your project dir:
Windows:
rd /s /q ".git"
Linux/Mac:
rm -rf .git

I find the top answer little bit too complicated, although fully functional. So here is maybe little bit easier to understand practice:
Assuming you already have project, and you want to change target (Bitbucket in my case) directory.
Go to project directory: cd Your/project/location
Find your current remote: git remote (its name will be probably origin)
Delete it: git remote remove yourOldRemoteName
Make sure you deleted the remote: git remote (should display nothing)
Create new remote: git remote add yourNewRemoteName repositoryUrl
(If you are using Bitbucket, your url will be something like https://yourUsername#bitbucket.org/your-company/yourRepository.git and you will find it by clicking Clone button in source folder of your repository or when creating the repository.)
Hope this will be useful!

If you delete a git repository from github, you should also delete a folder name .git from your Android Studio root directory.
Then you have to close the project. And re-open it in Android Studio.
Then do these things:
1) VCS -> Enable Version Control Integration -> Git
2) In Project view in Android Studio, select the project root folder and right click on it. Then go to Git -> Add, after that Git -> Commit Directory, and then Git -> Repository -> Push .
Whenever you get prompts in this way, just click on appropriate options.

Remove the git folder in Project directory
Run this command git init in Terminal
Vcs=> Git=>remote and add new
Paste the new git URL
After, verify your GitHub credentials
Now new git attached to your project

Remove and add git
//progect_path is path where .git is located
cd <progect_path>
rm -fr .git
git init

For me, the better solucion using Android Studio with Flutter projects was:
Create a new project in Android Studio
Close Android Studio
Outside from Android Studio, with Finder (Mac) copy from my old (corrupted) project the entire lib folder and the pubspec.yaml file to the new one, overwriting.
Enable Git in the new project from Android Studio again

Related

Git always turned on even after creating new project

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.

how connect myProject to mainProject on github (Android Studio)

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 github project

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

How to push an existing Android project to GitHub repo using .gitignore file?

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.

Bitbucket with android :"Can't publish part of repository" error

I have recently use Android studio and I was just try to connect bitbucket with it.
I don't want manually bitbucket by terminal thas why I googling it. find some links link .
I have follow all the steps install plugin>shareproject>login>private>share project
and than error. I checked my bitbucket but no repositary created.
Can't publish part of repository
Invalid VCS root mapping The directory
ExpandableLayout-master\TestProject is
registered as a Git root, but no Git repositories
I don't know is thare error of plugins of bit bucket or my android studio
After to much research... finally i got answer
Actually it is bug of bit-bucket plugin. bit-bucket bug
Here is solution given by AKAMUZA in above link thanks bro.
(1)Go to project folder and delete .git folder
(2) IDEA pops up an error message about project not being under version control and an option to configure it. Press Configure and just delete the path to your project in VCS section.
(3)After this Import into version control -> Share project works like a charm.
UPDATE
I Found many developer having issue after use plugin directly from Android studio and if It not work you can download below plugin
https://bitbucket.org/dmitry_cherkas/jetbrains-bitbucket-connector/downloads/jetbrains-bitbucket-connector_IC-139.224.zip
Go to Setting-> Plugin-> Install plugin From disk ->above downloaded plugin -> install & resatart.
You can feel Magic after restart :P
I have the same problem with android studio.
this is my suggested solution:
go to project root folder
then open a terminal in this folder:
git init
git add --all
git commit -m "your message"
then go to bitbucket and create new repository then choose "I have an existing project" ...
Now you can use plugin to push/update
This thread mentions (assuming that File > Settings > Version Control is set to "git"):
You could instead have navigated into the directory via a terminal or shell and typed 'git init'. That would have converted that directory into a git repository.
So check if ExpandableLayout-master\TestProject has or has not yet a .git subfolder in it.
If not, it means you have declared that path as a git repo, but locally, on your disk, that folder is not yet a git repo. If so, you can initialize it, add a remote pointing to an empty bitbucket repo and push.

Categories

Resources