I just commited 2 changes in /frameworks/base, but when I type repo sync -f -j5 at the end of the sync the changes are gone and it says
Fetching projects: 100% (494/494), done.
Syncing work tree: 100% (494/494), done.
frameworks/base/: discarding 2 commits
In frameworks/base I just did git fetch /repo/project, git cherry-pick xxxxx and git commit. Nothing else.
Any help would be appreciated :)
repo sync -f will convert to a detached header status.
you can enter /frameworks/base, use command git branch -a to find the branch you just commit in. and git checkout to switch to it.
Related
Git seems to be tracking the java folder, but I can't commit changes to the specific file MainActivity.java. I get a "Changes not staged for commit"
The diff shows the changes, but I can't commit it.
Also, I can't go down into the folder in Github.
That folder is not clickable.
Edit: When I do git status in the command line, I get
user:JustJava juil$ git status
HEAD detached at 93ea9a1
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: app/src/main/java/com/example/android/justjava (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
Edit 2: I have checked out the latest commit as some have suggested but still get the detached head error.
Edit 3: I tried adding the file itself w/ git add but got an error that the directory is a submodule.
JustJava juil$ git add app/src/main/java/com/example/android/justjava/MainActivity.java
fatal: Pathspec 'app/src/main/java/com/example/android/justjava/MainActivity.java' is in submodule 'app/src/main/java/com/example/android/justjava'
I tried running git submodule status and got the error
fatal: no submodule mapping found in .gitmodules for path 'app/src/main/java/com/example/android/justjava'
I tried deleting .git in the submodule, but the same error keeps popping up.
To correct this using just the Android Studio interface, try the following:
Make a backup copy of your changed files, just in case this method doesn't merge your changes correctly.
In the version control pane, select the Log tab. It will show you a list of commits.
The top commit should be the newest one. Right click it and select Checkout Revision in the context menu.
If a dialog appears, select Smart Checkout. This will merge your changes with the selected commit.
Your HEAD should now be attached, so you can commit normally now.
When your HEAD is detached, it means you did the commandline equivalent of:
git checkout <UUID of previous commit>
The grey folder that was created is called a submodule, it happens when you initialize a git repository inside another git repository. I would suggest removing the .git folder inside JustJava/app/src/main/java/com/example/android/justjava.
Using git through terminal, follow these steps:
Backup all the code in a different folder
**Remove JustJava/app/src/main/java/com/example/android/justjava/.git"
Checkout out master or the current branch you're on (default: master)
In order to checkout master, go to the folder where you git project is through the terminal (linux or mac) or git bash (if you're on windows), then do:
git checkout master
Comparing backed up code with the current code and make the changes you want (if any)
Commit new code
Since justjava folder turned out to be a submodule, in the super directory, I called git rm -rf --cached justjava as suggested by #fusiongate and answered in this question.
This works in that it allows the file to be added and committed, but the commit history on this file is lost.
I'm building a ROM but I need a commit into /frameworks/base repo. So i "git fetch" the Github repo and then I type "git commit xxxxx", but the output is:
error: pathspec xxxxx did not match any file(s) known to git.
Any help?
You need to do these things in order..
Fetch All Branches
git fetch --all
Check Branch Name
git branch
Then Checkout to branch
git checkout your_branch_name
Now, while committing
Add all files you want to commit in the staging area
git add . (for all files)
git add filename (for respective file)
Commit to local database
git commit -m "your custom message"
Push to remote repo
git push origin current_branch_name
Here, origin is the remote name.
Try
git checkout -b yourbranchname
And then try again.
I think you should clarify some concepts of git before using.
1) 'git fetch' only update those refs to remote branches, it do not merge remote modifications to your worktree. You need run 'git pull' to merge with your worktree.
2) you need a branch to work on. You can run 'git checkout -b' to create a new one, or 'git checkout --track' to create one tracking remote branch.
I'm new to git. I want to create a new project with Eclipse, and use Github to manage it.
The problem is, Github suggested me to add a .gitignore file to let it ignore files in bin, but once I did that, there is a new master in the Github's repository.
Then when I tried to push my project, it said:
To git#github.com:Benjaminz/SocialEventPlanner
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:Benjaminz/SocialEventPlanner'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
When I ran pull it said:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
What mistake did I make? How to correct this?
Thank you. :)
it seems that ur poject is not stashed
Do Below Steps :
git stash
git pull
git stash pop
For the second error message, you can type:
git branch -u origin/master master
Then try again your git pull.
I need to download src code of different android tags. Each time it takes half an hour and GIGS of space. Instead I'd prefer to switch to different tag. How can I do so?
cd android-4.0.4_r1.1
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r1.1
repo sync
cd ../android-4.2.2_r1
repo init -u https://android.googlesource.com/platform/manifest -b android-4.2.2_r1
repo sync
What's the proper way to switch/update from android-4.0.4_r1.1 to android-4.2.2_r1?
As mentioned in the comments of the accepted answer, you can change the default revision in manifest.xml. There's a snippet about it in repo help init:
Switching Manifest Branches
To switch to another manifest branch, repo init -b otherbranch may be
used in an existing client. However, as this only updates the manifest,
a subsequent repo sync (or repo sync -d) is necessary to update the
working directory files.
This won't download everything fresh, but will perform the necessary git operations to checkout the correct branch/tag across projects. Actually, if you run it with --trace, you'll see it does a good bit more than just git checkout.
NOTE: If you use this method you must make sure you supply the exact same parameters to repo init as you had for your previous invocation. Specifically, if you supplied -g options, supply them again or repo sync will remove directories now unnecessary in the new set of groups.
You can fetch tags with :
git fetch
git fetch --tags
And do checkout by :
git checkout tag_name
Also if it is taking more time to sync than usual run below command in that repo :
git gc
I'm playing with the Android source code and I would like to switch to 2.3.3 and make some modifications from there. How do I do this?
More specifically, I made a git clone of the Launcher2 project and would like to switch it to the android-2.3.3_r1a tag. I tried,
git checkout android-2.3.3_r1a
but Git seems to think I'm trying to make a new branch instead.
I also tried
git branch -r
which listed
origin/HEAD -> origin/master
origin/eclair
origin/eclair-passion-release
origin/eclair-release
origin/eclair-sholes-release
origin/eclair-sholes-release2
origin/froyo
origin/froyo-plus-aosp
origin/froyo-release
origin/gingerbread
origin/gingerbread-release
origin/master
origin/tools_r7
origin/tools_r8
origin/tools_r9
and then
git checkout origin/froyo
but nothing seems to happen (files are unchanged) and
git branch
still outputs "* (no branch)".
all you need to do is git checkout -t origin/android-2.3.3_r1a. This will give you the branch you want and track the remote one.
Try:
git checkout -b android-2.3.3_r1a origin/android-2.3.3_r1a
Or:
git branch android-2.3.3_r1a origin/android-2.3.3_r1a
git checkout android-2.3.3_r1a