How to begin committing via git to bitbucket – Not seeing changes

Perhaps I am going about this wrong, but I am following git tutorials as is. I have a repository on bitbucket called “testrepos” and I am trying to work with it.

First, I clone it with git clone https://my_username@bitbucket.org/my_username/testrepos.git

  • Preventing certain files from being pulled in git
  • Bare repo: Not all refs have been pushed
  • Git run server side hook when there are no updates
  • Deploying to Different Web Servers via Git
  • Git: Confusion about merge algorithm, conflict format, and interplay with mergetools
  • What's a good way to organize a large collection of personal scripts using git?
  • Now, the repo is empty, so I made a file called main.cpp. I then run “git add main.cpp”. If I run git status now, I see that there is a new file called main.cpp to be committed.

    Finally, I run git commit -m 'First commit'. There are 0 changes, 0 insertions, and 0 deletions! Why are my files not committing? I am using push and pull as well.

    edit Here is the full log:

    Welcome to Git (version 1.7.7-preview20111014)
    
    Run 'git help git' to display the help index.
    Run 'git help <command>' to display help for specific commands.
    
    chris@EDI ~
    $ cd git
    
    chris@EDI ~/git
    $ git clone https://my_username@bitbucket.org/my_username/testrepos.git
    Cloning into testrepos...
    Password:
    warning: You appear to have cloned an empty repository.
    
    chris@EDI ~/git
    $ cd testrepos/
    
    chris@EDI ~/git/testrepos (master)
    $ git pull
    Password:
    Your configuration specifies to merge with the ref 'master'
    from the remote, but no such ref was fetched.
    
    chris@EDI ~/git/testrepos (master)
    $ git add temp.cpp
    
    chris@EDI ~/git/testrepos (master)
    $ git status
    # On branch master
    #
    # Initial commit
    #
    # Changes to be committed:
    #   (use "git rm --cached <file>..." to unstage)
    #
    #       new file:   temp.cpp
    #
    
    chris@EDI ~/git/testrepos (master)
    $ git commit -m 'Committing temp file'
    [master (root-commit) 5d659df] Committing temp file
     Committer: unknown <chris@EDI.(none)>
    Your name and email address were configured automatically based
    on your username and hostname. Please check that they are accurate.
    You can suppress this message by setting them explicitly:
    
        git config --global user.name "Your Name"
        git config --global user.email you@example.com
    
    After doing this, you may fix the identity used for this commit with:
    
        git commit --amend --reset-author
    
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 temp.cpp
    
    chris@EDI ~/git/testrepos (master)
    $ git pull
    Password:
    Your configuration specifies to merge with the ref 'master'
    from the remote, but no such ref was fetched.
    
    chris@EDI ~/git/testrepos (master)
    $ git push
    Password:
    Everything up-to-date
    

  • git - how to get the full message from git merge --log
  • Delete everything and upload new version
  • How do you process a Gitlab merge request?
  • Added commits in the wrong git repository
  • filter-branch --index-filter always failing with “fatal: bad source”
  • Git How to commit after closing editor?
  • 5 Solutions collect form web for “How to begin committing via git to bitbucket – Not seeing changes”

    You really do need to do git push origin master, rather than just git push. This is because the default behaviour of git push is to push each branch to one with the same name on the remote side, so long as a remote branch with that name exists. In this case, your BitBucket repository is completely empty (without a master branch, since there are no commits) so no branches will be pushed by the default behaviour of git push or git push origin. Your push will work if you do:

    git push origin master
    

    … but since this is your first push, you should do:

    git push -u origin master
    

    … which also sets the master branch in origin to be the default upstream branch for your master branch. You only need to use this form of the command once.

    Try git push origin master.

    Was the file you added empty? The message is showing you the number of changes files, and the number of lines inserted and deleted. If you just added an empty file, git doesn’t count that as “changed” in the numbers it’s generating. It DOES, however, commit the file.

    Try to push back up to bitbucket, and view the repository file listing in a web browser. You should see your file there.

    I have had this issue as well, and I have seen a lot of unhelpful advice. Finally, I broke down and read the code for git-pull and git-fetch. In my case, the problem is caused by having “tagopt = –tags” in the configuration file for the remote in question. This seems to cause git-fetch to do “automated tag following” which has a bad side-effect of truncating the FETCH_HEAD file in some cases. This in turn causes git-pull to fail with the error:

    Your configuration specifies to merge with the ref ‘master’
    from the remote, but no such ref was fetched.

    I am really not confident enough with the internals of git to say if this is a bug or intended behavior or just me not understanding git very well. However, removing “tagopt” settings from my config files has solved the problem for me in all instances.

    Note, this is particularly confusing because manually running “git fetch –tags …” takes a different code path and FETCH_HEAD is left in good shape.

    (I am running git version 1.7.4.1)

    git push -u origin –all

    for first time

    git push origin –all

    afterwards

    is whats listed on bitbucket 101

    https://confluence.atlassian.com/display/BITBUCKET/Create+a+repository

    Git Baby is a git and github fan, let's start git clone.