github,eclipse and android - android

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.

Related

How can I solve "fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree"?

I have only one commit on master and haven't merged it into the remote. I want to remove my commit, keep my changed files, change my branch, and commit them.
Now I have used git reset --soft HEAD~1, but I am faced with this error:
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
HEAD~1 is a way to point at "the parent of current commit"
In your situation: the (only) commit on master does not have a parent ...
If your intention is to have this commit on another branch, simply create that other branch:
git checkout -b my/branch
# The above is a shortcut to:
git branch my/branch # Create a new branch `my/branch` on the current commit
git checkout my/branch # Switch to this branch
With one single commit in its history, "removing the commit from master" is the same as "deleting master".
There is no harm in doing it (you can re-create it later): git branch -d master, but you can also live with a local master branch hanging around.
An alternative is to amend the first commit:
# Make your change in the file(s)
git add file_changes
git commit --amend --no-edit
Resource: How can I add a file to the last commit in Git?
If this is from flutter, then the problem is simply from your installation process.
check your .git > refs , if the heads & remote directories are empty, then you simply have incomplete files.
Delete your current flutter folder and download again.
Ensure that 100% of the files are moved/copied during extraction

Getting "detached HEAD" error despite deleting git submodule

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.

Error when typing "git commit"?

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.

Discarding commits at the end of the repo sync?

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.

Switch to a specific version of Android source code

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

Categories

Resources