I executed these commands on intranet server (initialized empty Git repository in /home/git/project/):
mkdir project
cd project
git init --bare
Then I executed these commands on client:
git clone git#server:project
Then copied android source code (directory: alps/) to project
git status
git add .
git commit -m "xxx"
git push origin master
When this operation was done, I deleted the project and cloned it from server again. Some files were lost (e.g.:some .mk files in alps/external/chromium_org)
Why did it happen?
Most probably you've got the .mk extension in your .gitignore file. The file is in the project root directory. It may be hidden.
If you're sure that you want .mk files under source control, find a line with it in the .gitignore and delete that line.
Then:
git add .gitignore
git commit -m'removed .mk from .gitignore'
git add --all
git commit -m'tracked .mk files'
By the way, a good sample of .gitignore for Android can be found in GitHub default .gitignore files.
Related
Not all folder in project uploaded to github as default. Is it ok?
such folder build not uploading to git as default. any reference about it? should I leave it or including folder build too?
How to do that?
Thank you
By default build/ is part of .gitignore that is why it's not been uploaded on remote. This is perfectly fine.
Even if you wish to include it into remote repository.
git rm --cached .
git add -A
git commit -m "Message of your choice"
git push origin branch_name
Android projects now are created with a .gitignore file. gitignore specifies intentionally untracked files to ignore. So one of the files that are specified in gitignore is the build folder. Therefore when you commit, it doesn't get uploaded to git as default. You should leave it alone but if you want to, you can simply remove the build folder specified in .gitignore.
You can also look at this post as well. Hope this helps!
From the title of my question you can see what my problem is. I have an app on GitHub but I don't have .gitnore file. Now I want to make that file. I read somewhere that I must delete some files with terminal(Ubuntu) and then to make new .gitnore file.
Could someone tell me how to do all that stuff?
EDIT: I followed a solution from another question but when I write it into the terminal I received this:
dev3#dev3-All-Series:~$ git rm --cached
fatal: Not a git repository (or any of the parent directories): .git
dev3#dev3-All-Series:~$
You can remove the files on your local machine, and push to the repository. If the files are removed there, thén you can make the .gitnore file. That way, you don't end up with useless 'dead' folders or files on your repo. This way you don't need local access to the files, just your git client.
If you add the .gitnore first, you won't be able to delete the files because they will be ignored :).
If you already have a .gitnore file setup, you can do the following to remove files:
You can remove them from the repository manually:
git rm --cached file1 file2 dir/file3
Or, if you have a lot of files:
git rm --cached `git ls-files -i --exclude-from=.gitignore`
But this doesn't seem to work in Git Bash on Windows. It produces an error message. The following works better:
git ls-files -i --exclude-from=.gitignore | xargs git rm --cached
(found that solution here)
Iv'e added:
*.iml
to all of the gitignore files in my project.
They are still being tracked, even after committing the .gitignore.
The safe option is to remove the iml file from your staging index.
git rm --cached <path to iml file>
git will track the files sometimes even if you added the file which shouldn't be tracked in .gitignore
In that case you should remove the cache first then add all.
Important : Before, commit or stash your current changes
$ git rm -r --cached .
$ git add .
$ git commit -m "file tracking - changed"
When you added them one time, they will keep tracked!
You have to retrieve all commits till the one where you commited the .iml files.
Here is a good post on SF about reseting commits in git:
How to revert Git repository to a previous commit?
I m collaborating with another developer over git. Our setup environments are different. To avoid adding the correct sdk and other libraries I decided to include this line in .gitignore
#eclipse
project.properties
but in the initial commits my project.properties file was pushed onto the repository. I thought updating the .gitignore file would take care of this problem on the other developers machine. But every time he pull the repository he has to update the project with the path of his sdk and library to be able to run the code.
If you want to ignore a file within your git repository that was already tracked by the system, you have to delete the file from the repository cache. After deleting the file, you can add the ignore rule to your .gitignore file and it will be ignored by the repository.
First: Delete the file from the repository cache
git rm --cached path/file
Second: Add the ignore rule to your .gitignore file
path/filename
Third: Commit the updated .gitignore file
git add file
git commit -m "Updated .gitignore rule"
git push
found here:
http://www.wegtam.net/article/add-file-gitignore-was-already-tracked
The Android source is a large hierarchy of git repositories. They are managed by a custom script called repo. Repo determines which git repositories to manage using a manifest.xml. The manifest.xml of Android is hosted in a git repository along with all the other git repositories.
How is this repository managed in Android? Specifically how are the different branches and the different files hosted in each branch organised?
First, repo init creates the .repo directory, clones the git repository https://android.googlesource.com/tools/repo to .repo/repo, and the git repository specified with the -u option to a bare repository at .repo/manifests.git. After that, it creates the .repo/manifests directory, converts it into a git repository through creating symbolic links from .repo/manifests/.git to .repo/manifests.git. It then checks out the branch specified in -b, and creates a symbolic link .repo/manifest.xml pointing to the specified file (-m option) in .repo/manifests, by default .repo/manifests/default.xml.
Roughly as follows:
repo init -u $URL -b $BRANCH -m $MANIFEST
--------------------
mkdir .repo; cd .repo
git clone https://android.googlesource.com/tools/repo
git clone --bare $URL manifests.git
mkdir -p manifests/.git; cd manifests/.git
for i in ../../manifests.git/*; do ln -s $ı .; done
cd ..
git checkout $BRANCH -- .
cd ..
ln -s manifests/$MANIFEST manifest.xml
You can trace what really happens with repo --trace init ...
Then, repo sync clones git repositories to .repo/projects for each project in manifest.xml and local_manifest.xml, creates working directories with .git having symlinks to the corresponding bare repository, checks out the branch specified in the manifest, and updates .repo/project.list. The case where the projects are already there is slightly different, essentially performing a git pull --rebase.
At the root of the repo is a hidden directory named ".repo". Inside you will find a git project named "manifests" which usually contains a file named "default.xml". This file contains information about all the projects and where their associated git repositories are located. This file is also versioned thus when you use the "repo init -b XYZ" command it will be reverted and you can back to older branches that may have added/removed git projects compared to the head.
Here is a link to the git repo document describing the manifest format:
https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md