Ok I'm having this issue. I pushed (fresh repo) my Android app to my repo on Github from Android Studio. I then pulled it from AIDE on my tablet. I received no errors, even after pulling, from Android Studio. However, when I use AIDE I get errors such as invalid pack declaration (it's setup correctly). I change it to how it appears in the path, it works just fine (even tho in Android Studio my original setup was right). After that I get a bunch of errors saying R is an unknown entity. R.Java is present, so that's not it. I added the suggested import and that branches off to more errors.
Edit
The commands I have been using are as follows:
On initial setup:
cd C:\...path here
git init
git add .
git commit -m "First commit"
git remote add origin <urltorepo>
git remote -v
git push origin master
updating:
git add --all
git commit -m "message"
git push origin master
and this is what I've been getting:
warning: LF will be replaced by CRLF in <file>
The file will have its original line endings in your working directory
Fixed by recreating the repo and leaving the "Initialize this repository with a README" check blank
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'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.
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.
I cloned a repo from Github. It was an eclipse Android project. I then imported it into Android Studio and have now got it up and running. I ran "git init" and am now trying to create a branch to work off of.
when I run git branch I get nothing. Terminal returns nothing and just goes to the next line. i have tried running git branch -a and git branch --list and still am getting nothing. There is no master branch showing or any branch for that matter.
I ran git checkout -b and it said the branch was created. But when I run git branch I still get nothing returned. I then tried to run git checkout master and received:
git checkout master
error: pathspec 'master' did not match any file(s) known to git.
I am not sure why this is happening and think it has something to do with the weird initial setup. (clone repo, then import into android studio, then run git init)
git init is for initializing a new git repository. Since you cloned from an existing repository on Github, there is no need to initialize a new one.
In general, if you git init to initialize a new repo, and then immediately invoke git branch without making any commits or creating any branches, then the behavior you experienced is expected: git branch will return nothing. Only after your initial commit (or you explicitly create a branch) will you see any branches listed.
In particular if you ran your git init and git clone in the same directory where you ran git clone to begin with, then you will not see any branches. If you change directory into the subdirectory that was created when you cloned, then git branch will probably list master for you (and git remote show origin will show you the remote branches).
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. :)