How to push local changes to a remote git repository on bitbucket

前端 未结 4 1861
情歌与酒
情歌与酒 2020-12-22 15:57

I\'m testing out Git and Bitbucket.

I\'ve created a repository on Bitbucket and have created a local copy of the repo and I am committing files into it. I can\'t see

相关标签:
4条回答
  • 2020-12-22 16:33

    This is a safety measure to avoid pushing branches that are not ready to be published. Loosely speaking, by executing "git push", only local branches that already exist on the server with the same name will be pushed, or branches that have been pushed using the localbranch:remotebranch syntax.

    To push all local branches to the remote repository, use --all:

    git push REMOTENAME --all
    git push --all
    

    or specify all branches you want to push:

    git push REMOTENAME master exp-branch-a anotherbranch bugfix
    

    In addition, it's useful to add -u to the "git push" command, as this will tell you if your local branch is ahead or behind the remote branch. This is shown when you run "git status" after a git fetch.

    0 讨论(0)
  • 2020-12-22 16:36

    I'm with Git downloaded from https://git-scm.com/ and set up ssh follow to the answer for instructions https://stackoverflow.com/a/26130250/4058484.

    Once the generated public key is verified in my Bitbucket account, and by referring to the steps as explaned on http://www.bohyunkim.net/blog/archives/2518 I found that just 'git push' is working:

    git clone https://me@bitbucket.org/me/test.git
    cd test
    cp -R ../dummy/* .
    git add .
    git pull origin master 
    git commit . -m "my first git commit" 
    git config --global push.default simple
    git push
    

    Shell respond are as below:

    $ git push
    Counting objects: 39, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (39/39), done.
    Writing objects: 100% (39/39), 2.23 MiB | 5.00 KiB/s, done.
    Total 39 (delta 1), reused 0 (delta 0)
    To https://me@bitbucket.org/me/test.git 992b294..93835ca  master -> master
    

    It even works for to push on merging master to gh-pages in GitHub

    git checkout gh-pages
    git merge master
    git push
    
    0 讨论(0)
  • 2020-12-22 16:37

    Meaning the 2nd parameter('master') of the "git push" command -

    $ git push origin master
    

    can be made clear by initiating "push" command from 'news-item' branch. It caused local "master" branch to be pushed to the remote 'master' branch. For more information refer

    https://git-scm.com/docs/git-push

    where <refspec> in

    [<repository> [<refspec>…​]
    

    is written to mean "specify what destination ref to update with what source object."

    For your reference, here is a screen capture how I verified this statement.

    0 讨论(0)
  • 2020-12-22 16:41

    Use git push origin master instead.

    You have a repository locally and the initial git push is "pushing" to it. It's not necessary to do so (as it is local) and it shows everything as up-to-date. git push origin master specifies a a remote repository (origin) and the branch located there (master).

    For more information, check out this resource.

    0 讨论(0)
提交回复
热议问题