Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to Bitbucket repo silently fails and nothing changes

Tags:

git

bitbucket

In the past I've used svn and cvs, but never BitBucket or Git. I just got a BitBucket account with an empty project associated.

I read Getting Started with Bitbucket and on my BitBucket page that I am supposed to do the following:

git clone https://bitbucket.org/REST_OF_URL/...

I use the URL provided by Git; it successfully accepts my password without any trouble. It does, however print the following:

warning: You appear to have cloned an empty repository.

This made sense to me, because I just signed up for BitBucket.

This makes a directory called myproject. I then copied a file to that directory and added it to the repository:

cd myproject
echo 'Hello Git!' > hello.txt
git add hello.txt

I checked the status:

git status

and saw that hello.txt was recognized as a new file.

I then tried to push the file to the server:

git push https://bitbucket.org/REST_OF_URL/...

again, I typed in my password and it didn't complain. It reads:

Everything up-to-date

But the file has not shown up in my online Git project. I also noticed there is a git commit command. I tried this as well:

git commit -m "Initial project set up"

The output reads:

Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate.

Since the file still hasn't shown up in my directory, I feel like I must have made a local commit on my own machine. Can anyone help me by telling me

  • What I'm missing to set up a simple project with Git
  • Where I've committed these files on my local machine (I'm hard up for disk space and don't want any clutter)

As another user experienced from the Git BitBucket manual it transfers only when you push with

git push origin master

but does not work when you push with

git push

This resolves my issue, but I still do not know why this happens.

like image 910
user Avatar asked Nov 17 '11 21:11

user


People also ask

Why is git push not doing anything?

You need to use git pull and resolve the difference between your local changes and the remote changes before you can git push . There is still a commit in the remote branch initializing the repo that may not be in your local version.

Why isn't my git push is not working?

It may be possible that push permission is not provided to the user pushing the code changes. I suggest checking the user permissions. If the push permission is present, then it may be possible that there is a pre-push git hook in the repo and your push isn't in accordance with it.


2 Answers

The simple solution is push with master branch at first time:

$ git push origin master

Then after that, you can use git push for default push to Bitbucket (master branch).

like image 196
Enze Chi Avatar answered Oct 12 '22 23:10

Enze Chi


git add only adds the file to your local index so that it is ready to be committed. You first need to git commit (which you did), then git push your commits to BitBucket so they will show up there.

You are correct in your belief that you are making commits locally. This is perhaps one of the defining features of a decentralized version control system (DVCS). You have a full copy of your project history on your local computer. When you git push, you send the commits you did locally to BitBucket.

Your project folder should have a .git directory at its top level. This is where all the metadata is going.

like image 42
Jack Edmonds Avatar answered Oct 12 '22 22:10

Jack Edmonds