I'm not new to using GitHub on Android Studio, but:
This is my first try to contribute to a sample project for Android on GitHub.
I did the following
I cloned the repository:
I made my changes
I committed my changes
I pushed my commit
And baam (here is the problem):
Why? What things did I miss?
(Don't forget, I have never contributed on GitHub, and this is my first time.)
403 indicates that you are not allowed to access the resource - you aren't authenticated with GitHub. To fix this, you should change your remote URL to a repository you have access to, then push your changes:
https://myusername#github.com/user/repo.git
From the command line you would need to do the following (Android Studio should automatically detect the changes):
git remote remove origin
git remote add origin https://myusername#github.com/user/repo.git
git push -u origin --all // prompts for authentication, pushes your changes to github
Your question has nothing to do with Android Studio, I guess if you try to push your changes through command line you'll get the same result. Read about Contributing to Open Source on GitHub.
First of all, to do a contribution:
You must fork the repository
Clone your fork version of that repository
Through the command line, navigate to your clone directory then add upstream version (original repository):
$ git remote add upstream https://github.com/fcannizzaro/material-stepper.git
You can check it using the line $ git remote, and you will see origin and upstream.
Make changes → commit them → then push (all of this happen on your repository (forked one), not the upstream).
Go and check the network graph for both the forked and original repositories.
Go to the GitHub original repository's link and click pull request.
Do as described in this image:
And fill the others field and click Create pull request
Thanks for Erik Carlsten's tutorials.
Related
I want to create an object detection application using clarifai android library found in the following link:
clarifai android
The documentation is very clear but the problem is in cloning the clarifai-android-sdk using git-lfs
and this what is mentioned in the documentation:
1) Git LFS
Before doing anything else, please make sure you have Git-LFS
installed on your system. The binary contained in the framework is
managed by GitHub using git-lfs.
If you don't have it installed yet, you can find details at:
https://git-lfs.github.com. IF YOU DON'T HAVE GIT-LFS INSTALLED, THE
SDK WILL NOT WORK.
2) Verifying the SDK
After setting up Git LFS, please ensure that the SDK
cloned correctly, by checking the size of the *.aar. If the size is
less than ~120MB, then you will need to re-pull master now that Git
LFS is set up.
If you downloaded a ZIP of the project via the "Clone or download"
button, the SDK will be cloned incorrectly. Either clone the repo with
git, or download the *.aar file specifically by clicking on the file
through GitHub, and clicking the "Download" button.
if it is not clear this is a link of the full clarifai-android-sdk documentation
I have already installed git-lfs but when I try to clone the repository of clarifai-android-sdk the size of '.aar' file is 100 megabyte not as mentioned previously that:
if the '*.aar' file is less than 120 megabyte then you will need to
re-pull master now that Git LFS is set up.
so generally: I need to know what should I do to solve this problem ?
and specifically what is the meaning of re-pull master now that Git LFS is set up.
I would think that doing a git pull would solve that (yeah its unusual to do it right after a git clone but that seems to be what it is saying.
So I have an android studio project that I'm syncing between my laptop and my computer with git. Every time I push with one and pull with the other when I try to pull I get error refusing to merge unrelated histories
I tried using --allow-unrelated-histories but that causes a ton of merge conflicts.
I need to be able to sync between the two because my computer supports the emulator and my laptop is portable.
This happens because your repositories was initialized independly.
You should create the repository only in one location, and clone it to the other.
If the other repository already exists and you have there some change which you don't want to lose, you could do the following:
(from location2, commit all uncommitted changes first!)
git fetch location1
git branch save_location2
git reset --hard origin/location1
So you switch to the history started at location1, and would not lose your history started at location2, and will be able to look up stuff from there.
There are exceptional cases where you should use --allow-unrelated-histories, but I'm sure it is not your case.
I had same problem. Try this:
git pull origin master --allow-unrelated-histories
git push origin master
Reference:- Github unrelated histories issue
I'm stumped.
My project has it's original GitHub repository.
I will have to push the Android project to a second repository.
How to do push code to a second and separate GitHub repository in Android Studio?
I see hints that it's possible, but I don't know how to initiate to new repository.
Regards,
You can do so by either editing or adding remote URL from terminal.
To add:
git remote add origin2 https://github.com/user/repo.git
To edit:
git remote set-url origin https://github.com/user/repo.git
Then you can push to another remote repository.
In Android studio, you can press Ctrl+Shift+K and choose where to push the commits.
Follow these steps:
Go to the android project directory and open terminal then.
1.git init
2.git remote add bitbucket https://github.com/xxx/yyy.git (bitbucket is name i have given. you can use anything like origin2 etc.)
3.git add .
4.git commit -m "first commit"
5.git push -f bitbucket master
We have been using gerrit as our android source code repo. We usually use git bash
commands to do push ,pull and commit for working with gerrit.I want to how we can configure the android studio itself with gerrit so that i don't need to type in commands in git bash. I tried to change some settings in the Android studio in git version control option but that really didn't work.
One more thing is that whenever we do a commit through git commit command git creates (or something else i am sure as i am not very good at git commands and env) changeId: This is very important for pushing/amending the changes.How can i add changeId while i commit from studio.
Let me know if i am not very clear about my question , i will add more.
This is the image of my push Ui from studio where i can't see the origin HEAD :
Android Studio’s Git GUI should be able to do almost all the jobs through menus and buttons. The only annoying thing may be that you need to change the remote ref in the push menu from master or refs/heads/master to refs/for/master to create changes for review.
Change-Id is created by a hook commit-msg. As I know, it is under repo/hooks if you use Google’s REPO. The repositories cloned by repo sync have commit-msg deployed, so you don’t need to worry about it. But as for those repositories created by git clone or git init, you need to install it. Gerrit’s project page provides a clone command which includes scp that downloads and copies the hook automatically. If you clone through Android Studio, you could manually install it under .git/hooks/ for one repository, or copy it to $GITBASH/ming64(32)/share/git-core/template/hooks on Windows so that any new created repository will have it installed automatically.
Let's say I'm building Android or CyanogenMod from source and want to make changes to its source. Also, let's assume I don't want to submit these changes (since they are incomplete or are changes that have already been rejected, for example).
What is the best way to manage that? How can I have proper source control of my "personal" changes, but at the same time be able to use repo sync so that I have the latest changes?
Can I have local branches (for each project I make changes) and simply merge from the master branch to my local branches after every repo sync?
When you run "repo sync" what actually happens is that each git repository is rebased on a new upstream. If you don't have any local patches in a specific git repository, it's a simple fast-forward. If you do have some patches and upstream does as well(your branch and upstream branch have diverged), repo will attempt an automatic rebase.
So lets say you have a patch on top of upstream code, and upstream has had some new comits since you applied that patch. When you run repo sync, repo will try to rebase your code on top of upstream. If the automatic rebase fails, repo will throw an error message letting you know that you should fix the patch manually.
To sum it up: You can create a branch in each project you want to modify, store your commits on that branch. Repo sync will automatically rebase your patches(unless it fails and then you'd have to apply them manually).
You will need to use repo start command to create a topic branch that tracks the remote repo branch. Or you need to use --track option of the git branch command to manually create a local branch with a remote tracking branch. Use the --set-upstream option of the git branch command to add a tracking branch to an existing local branch.
Once you have setup the tracking branch correctly, the repo sync command will fast forward and reapply your local patches as Anton Cherkashyn has described in his answer.
Use gerrit in conjunction with repo and git.
This seems to work for me.
First mentioning some setup
# cd to root of source tree
repo start MyBranch # Create working branch for all projects
repo checkout MyBranch # switches all projects to use MyBranch
Time passes, fabulous edits made and committed (in MyBranch), working branch is clean. Now want upstream changes ...
# Current active branch is "MyBranch"
# The following sync -d as per repo docs:
# -d: switch specified projects back to the manifest revision.
# Helpful if the project is currently on a topic branch,
# but the manifest revision is temporarily needed.
# In other words, it automatically syncs default manifest's upstream
repo sync -d -j12
# Active branch may be "MyBranch" or possibly a detached head or whatever.
# So, if necessary, switch back to MyBranch
# - I usually do this just to make sure all projects are in MyBranch
# - NOTE: If a new project appears it won't have MyBranch
repo checkout MyBranch
# Now we're in MyBranch. Its "upstream" is our local master so sync it.
# - This is usually rather quick
repo sync
The "repo sync -d" may not be necessary but hasn't caused any problems as far as I have seen. Plus it pulls the master codeline locally to keep it in sync for handy diffs and such.
Perhaps "repo sync" from within MyBranch does that too. But I don't seem to get any updates when I omit the "repo sync -d" step and just do "repo sync" when MyBranch is checked out. (Although maybe my local setup is messed up somehow)
To summarize:
Option A: Might work
cd RootOfRepoSourceTree # wherever you have it
repo checkout MyBranch
repo sync
Option B: Works consistently for me
cd RootOfRepoSourceTree # wherever you have it
repo sync -d -j12
repo checkout MyBranch
repo sync