XCode and Github - ios

I'm trying to use git on an existing Xcode project by making a remote repo, but I can't push to it. I get this error: "The remote repository rejected commits. Make sure you have permission to push to the remote repository and try again." . I'm unsure why git makes the remote repo, but does not allow me to push. Could it be that my Xcode project is too large for the initial push?

The problem shouldn't be that your Xcode project is too large. You most likely are not allowed to push on the "master" branch because it is a protected branch. Is this your own remote repo or is someone else the owner?
If you want to push to the remote repo immediately, you can create your own branch off of master (if you are currently in the master branch) with
git checkout -b <branch_name>
To learn more about GitHub protected branches, check out GitHub Protected Branches

Related

Move code from one repo to another

I have a github repository called A. It's connected to heroku-A and the website is up and running. I did changes locally to the code, but I don't want those changes to show on repository A or heroku-A. I want to push the code to a totally new repo. How can I do this?
Here would be the procedure:
Create a new git branch (so that code is separate from your other repo)
git checkout -b <new_branch>
Add a remote pointing to your new repository
git remote add <new_repository_url> <new_repository_name>
Push the new branch to the new repository:
git push <new_repository_name> <new_branch>

Can't push from XCode to Github master branch

I created a new repository on github, modified the default readme file and then created a development branch to work on my project.
I have successfully commited and merged on development branch after it, sending all local modifications to github.
But when I try to push my local modifications to the master branch, XCode returns the following message:
The local repository is out of date
Make sure all changes have been pulled from the remote repository and try again.
And if I try to pull the changes..
How can I correctly push my project to the master branch?
You must do a git pull before you push to the server.
There are updates on the serer which you don't have on your repository.
git pull origin <branch
git push origin <branch>
When you try to push git verify that the latest commit from the server is in your local branch. if it does not - if you don't have it locally yo will be asked to pull the changes form the server before you can push your updates.

Trouble pushing changes to remote Git repo

I have started learning Ruby on Rails and Git.
Whenever I try to push any changes to my remote repo on Github, I encounter the following error:
C:\Sites\first>git push origin master
To git#github.com:piy9/Twitter_clone.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:piy9/Twitter_clone.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
NOte: I have added all the files in the directory and committed the changes. I have not created any separate branches using pull or checkout.
I am not asking for a solution to the problem.
doing
git push -f or
git push origin +HEAD
worked for me.
What I want to know is, why am I getting the error while trying to push to the original branch.
follow this and get everything works....
git branch production
git checkout production
#do some code changes
git commit -am "some desparate code changes to try fix heroku"
git push heroku production:master
Note: this will get your work done and will leave your previous branch.
or you can try this one also git push heroku +master
Looks like remote branch is ahead of yours, which means it contains something your local branch does not have. You may easily see commits on remote branch since when local branch was created or updated (assuming you run "git fetch origin/master" to fetch remote changes first):
git diff HEAD...origin/master
The output will answer your question why you are getting the error.
Now, my guess about the reason of the problem you have is that either someone has access to remote and pushed something, or you modified something using github editing interface and committed since last checkout/pull/merge. Using forced push as you did is not a good approach and it messes the history, it basically overwrites the remote branch with your copy, ignoring any remote changes.

Backing up work on a branch using heroku, rails and git

Rails/Heroku/Git newbie - here is my question. I have an app deployed with Heroku and am using the git repository hosted there as the only remote copy of my local work. I start making changes locally on a new branch and want to make this branch available on Heroku so that I can continue work on it from another computer. Heroku ignores branches other than master and I don't want to merge my changes yet (or push them as master). Is there a way to store/access my new branch via my Heroku git repository, or is it better to have another remote git repository for my work in progress.
Thanks!
You can push a local branch to the remote git server with:
git push origin branch_name
That way, you can pull it down again elsewhere with:
git checkout -b branch_name origin/branch_name
http://gitready.com/beginner/2009/02/02/push-and-delete-branches.html
http://gitready.com/intermediate/2009/01/09/checkout-remote-tracked-branch.html
I would go with a separate git repository as suggested - github.com or similar. Store your code there and deploy to Heroku's master repo - Heroku is a hosting platform afterall not a home for your repos.
ALTERNATIVELY Make use of dropbox and create your local workspace in a dropbox folder that is synced across multiple computers - I employ this method as well as git - plus you get the advantage that Dropbox is versioned so if you delete/change a file that you haven't committed yet you can get it back.

Is there a way I can view changes committed to my local GitHub branch without having to push it to the master branch?

I'm still figuring GitHub and Heroku out, so please bear with me. :)
I've a web app on, say, xyz.com. What I am doing now is to make some code/UI changes on some files, commit those files, push them to the master branch, and then refreshing the url to see these changes.
I think this is obviously the wrong approach, but I don't know of how else to test changes done to my code without having to push them on to the master branch. How could I do so?
I don't quite understand the situation in the full version of your question (see my comment and, as icc asks, why can't you test locally?), but to answer the question in the title, you can see the differences between your master and the version on GitHub by running:
git fetch github
git diff github/master master
(That's assuming that the remote that refers to your GitHub repository is called github - it might well be origin in your case. You can see all your remotes with git remote -v.)
To explain that a little further, when you run git fetch github, git will update all your so-called "remote-tracking branches" - in most cases those are the ones that look like origin/whatever, github/experiment, etc. Those are like a cache of the state of those branches, and they're only updated when you run git fetch or successfully git push to that branch on the remote repository. So, once you've done this to make sure that github/master is a recent snapshot of that branch on GitHub, you can happily compare it with your local master branch using git diff.
First: You don't push to the master branch, you push to a remote repo. You should probably read up on your git.
Second: This is not a good workflow, first you should commit your changes and then test them locally. When you are done testing you are ready to push your commits to a remote repo.

Resources