failed to push some refs - ruby-on-rails

Im trying to push to github
I follow the steps:
(before these lines Im located on my app directory)
$ mkdir estaciones
$ cd estaciones
$ git init
>>Initialized empty Git repository in /Users/armandodejesussantoyareales/Documents/project_newbie/Estaciones/estaciones/.git/
$ touch README
$ git add README
$ git commit -m "phase 3 estaciones"
>>[master (root-commit) 4462be3] phase 3 estaciones
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100755 README
(I don't know if that message is an error)
$ git remote add origin git#github.com:asantoya/estaciones.git
$ git push -u origin master
but always I have the same problem,late that I type that i got the next error
To git#github.com:asantoya/estaciones.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:asantoya/estaciones.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.

This means that the remote repository already has a master branch and it has stuff in that branch that has been added since you made commits to your local copy. This is referring to the code visible at https://github.com/asantoya/estaciones
Start by cloning the repo from github, then adding your changes to it, then pushing:
git clone https://github.com/asantoya/estaciones.git
git checkout -b nameofyourbranch master
Add some files etc.
git commit -a -m "Your commit message"
git push origin nameofyourbranch

Related

Cannot do a pull request because branch is "identical to main"

I want to do the pull request for my chapter_3.
However, it states that my main and chapter_3 are identical.
How to make my chapter_3 not identical with main? Below i also attached my git reflog
$ git add .
$ git commit -m "chapter 3"
$ git push origin chapter_3
Simply, in your local repository, add a new commit (or now commits) to chapter_3 and push.
Then, since chapter_3 has new commits that main has not, you will be able to initiate a pull request from chapter_3 to main.
The problem is: you were not on local branch chapter_3 when you did your commit. You were on main.
In order to avoid any mishaps, I would:
clone the repository again
create a chapter_3 branch
report your work for chapter 3 there (in the new local clone)
add commit and push
That is:
git clone https://github/com/<me>/<myRepo> newClone
cd newClone
git switch -c chapter_3
# work
git add .
git commit -m "Add chapter 3"
git push -u origin chapter_3
Then you can make your PR.
Notes:
replace <me> by your GitHub account name, and <myRepo> by your target repository name. Don't use < and >: they are placeholder makers.
replace newClone by a new local folder name which does not yet exist (it will be created by the git clone command).

one folder not uploaded in bitbucket

I am having some problems with bitbucket. All my project folders and files are uploaded except the src folder. The src folder in my computer has files and folders. But it is not appearing in bitbucket. Why is the src folder appearing like that in bitbucket?
I enter the commands:
git init
git add .
git commit -m "initial commit of full repository"
git remote add origin
https://boidurja#bitbucket.org/boidurja/kapstone.git
and I get this error:
F:\BOP consultancy and services\vuetify project\kapstoneui>git remote add
origin
https://boidurja#bitbucket.org/boidurja/kapstone.git
fatal: remote origin already exists.
And I enter this command:
git push -u origin --all
and I get this error:
F:\BOP consultancy and services\vuetify project\kapstoneui>git push -u
origin --all
To https://bitbucket.org/boidurja2/kapstone.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to
'https://boidurja2#bitbucket.org/boidurja2/kapstone.git'
hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Can anyone help?

Push up to the Bitbucket remote repository through gitbash command line

Created a repository on bitbucket. Trying to "push up" to the repository, though am unsure exactly what that means?
Also, and more importantly, I get an error when trying to execute two lines:
$ git remote add origin git#bitbucket.com/addyd/toy_app.git/src/master
fatal: remote origin already exists.
Addy#DESKTOP-6L1EGSI MINGW64 /c/Sites/environment/toy_app (master) $
git remote add origin git#bitbucket.com/addyd/toy_app.git/src/master1
Any help?
what it returned if enter the command git remote -v
if there is already a git remote origin exist it will print something like
origin https://bitbucket.com/addyd/toy_app.git(fetch)
origin https://bitbucket.com/addyd/toy_app.git(push)
if it is already there and pointing to the right repository do ACP
git add .
git commit -m "commit message"
git push origin branch
The right command to update change origin would be:
git remote set-url origin ssh://git#bitbucket.org/addyd/toy_app.git
But you shouldn't need to update origin if it was set before, and if you cloned successfully that repo: add some commits, and then:
git push -u origin master

failed to push some refs into repository

When I hit git command push for adding existing git repository to bitbucket newly created repository
git push vaibhav master
To https://bitbucket.org/thevaibhavpatil/notes_by_me.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://thevaibhavpatil#bitbucket.org/thevaibhavpatil/notes_by_me.git'
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.
So try this
git stash
git pull origin master
git add .
git commit -m "my message"
git push origin master

How to use git with XCode

I read the "How to Create a CocoaPod in Swift" and I got stuck when I tried to push to git:
cd ~/Documents/Libraries/RWPickFlavor
git init
git add .
git commit -m "Initial commit"
git tag 0.1.0
git remote add origin [Your RWPickFlavor Git URL]
git push -u origin master --tags
when I execute the last instruction,the terminal outputs that I don't handle protocol '[https'
Note: My git version is 2.3.2,and Pod version is 0.38.0
Are you sure you set up your remote URL correctly? You can check it with this command:
git remove -v
I suspect yours has square brackets in it, like this:
origin [https://github.com/...git] (fetch)
origin [https://github.com/...git] (push)
It should look something like this:
origin https://github.com/...git (fetch)
origin https://github.com/...git (push)
You can download the GitHub App and push to repository without using termal/commandline
aslong as you have ticked git repo when you created the xcode project

Resources