Something very weird is happening.
I am on the master branch of my repository. After calling git pull I get the latest version of the code on the master branch, everything is ok.
But for some reason, Android Studio, after some seconds, changes the code, so that now, even if I do git pull I get Already up-to-date but if I call git status I see changes not staged in red. How is that possible?
Also, if I click cmd+z I can see for few seconds how the code added by Android Studio goes away, and immediately comes back.
I tried deleting the entire project and cloning again from the repository, and again I get the latest version of the fresh code, but after few seconds Android Studio changes it.
All that happens in a particular file and section of code.
When you make git pull it doesn't reset or throw the changes you have non staged, you have to commit them the only reason you would see a problem with these files were is there was a conflict and git would notify you and tell you you need to commit before the pull.
so if you want to commit these change you need to do:
git add .
git commit
or if you want to throw away these changes you need to do:
git reset --hard HEAD
that last command would let you with the exact same code as in the remote repository.
That's happening because each time you opening a project with Android Studio, it will check for Android Studio project configuration files. When Android Studio did not find any of these files, it will create them. The configuration files will be in the .idea folder. Therefore, you will see a red mark for those unstaged files.
Related
Hello I am using Android Studio 2020.3.1 Patch 4. I'm using Git and committing a state. And then add some code and I want to return to where I was (before I entered the new code). When I checkout it does nothing. Even if I restarted Android Studio. And when I Reset Current Branch to Here.. initially it does nothing but if I restart the Android Studio new code is gone(as I wanted). What am I doing wrong?
The correct command to remove the newly added but not commited code is:
git stash
It will remove the unstaged codes and return the code-base to the last commit.
We normally use 'git checkout' to move around between different commits.
If you want to do this process without command, you will need to "Rollback changes". The keyboard shortcut for macos for this is: option + command + z.
I was working on an Android app, and decided to do an initial git commit. The project folder was on my desktop so I moved it into a newly created folder as to not make the Desktop into a git repository. The project was open in Android Studio when I moved it and made the commit, and when I went back to it it didn't work.
I closed it and reopened it and it wouldn't compile (I was a fool and didn't screen shot the error message) but then it started to work.
However, all the files in the project are in red, not the code itself, just the files that a visible in the tab on the left and the tabs at the tops of the open files. The project works but I want to get rid of the red as obviously it's an indication that something's not right.
I have to send this project for review tomorrow and I hope this won't create an issue for the recipient.
Thanks
The files are red because they have not been committed to git.
git add . and git commit -m "your commit message" should fix it.
And No it should not be a problem. I suggest you read more about git, it's a cool tool
In Android studio there are options at the bottom right corner to handle branches. In Merge option when I merge another remote or local branch, it shows me options like Force merge and smart merge.
What exactly they do?
When merging with local/remote branches?
its similar to Smart Checkout. Android Studio will stash local changes, check out the selected branch, and then unstash the changes. If a conflict occurs during the unstash operation, you will be prompted to merge the changes.
Smart merge executes the following commands:
git stash save "Uncommitted changes before Update at <MM/DD/YY>, <HH:MM>"
git merge <remote>
git stash pop (if merge successful)
If the merge is unsuccessful and you abort or discard changes, you'll need to run git stash pop yourself to get back your changes.
You can see the exact commands being executed by examining the Version Control context in Android Studio, in the Console tab:
I am using Android Studio 2.0 Beta 6 on Ubuntu GNOME. I am facing a strange problem. I am using git version control in my Android project. After building the project, when I click on commit changes through Android Studio GUI. The commit changes dialog box shows every file as changed. When I click on any file, it says contents are identical. I am attaching the screenshot below, clicking on any files says contents are identical.
So my question is, Why Android Studio shows files with identical changes in commit changes dialog and how can I solve it? I tried google but didn't found any related question.
It must be because of automatic file encoding changes by the IDE (In case you imported the project from somewhere else). Sometimes IDEs apply them automatically. Just revert the changes and do a clean and build. If the changes appear again, you will need to do a commit once and after that you'll be allright.
To verify you can just go to a normally behaving file. Open it in notepad and just save as from notepad with another encoding. It should show as modified thereafter in the version control window.
For me it was AS pointing to old git version. Please check the Settings\Version Control\Git
I ran into this issue as well. None of the typical culprits seemed to be at fault. As far as git (from the command line) was concerned, the files were unmodified, yet Android Studio still showed them as modified.
It turns out Android Studio and my command line terminal (cygwin) were using two completely different Git binaries. Android Studio was pointing to a Git installation I had made at some point in the past, while cygwin was pointing to /usr/bin/git, which had come from Cygwin's Git package.
I edited Android Studio's version control settings (as shown in Anton's screenshot) to point to the git.exe within my Cygwin distribution, then did a "refresh file status" from the VCS menu, and all the files went back to showing as unmodified.
We had to change the name of Bitbucket git repository. So when I loaded the project, Changes tab only had Local part.
I then edited .git/config file and update the url inside remote "origin" and restarted Android Studio.
But even then, Android Studio could not see the repository with a new url. And we only changed the URL.
Did anyone ever meet anything like this? Any idea how to fix it?
Funny thing, when I delete the complete project and re-clone it, Android Studio still does not see it. So I guess the error must be inside .idea directory, but I am not sure what file to edit inside this directory.