Git push error '[remote rejected] master -> master (branch is currently checked out)'

前端 未结 30 2316
半阙折子戏
半阙折子戏 2020-11-22 00:07

Yesterday, I posted a question on how to clone a Git repository from one of my machines to another, How can I \'git clone\' from another machine?.

I am now

30条回答
  •  粉色の甜心
    2020-11-22 00:32

    Here is one test you can do to see how the bare server stuff work:

    Imagine you have a workstation and a server with live site hosted on it, and you want to update this site from time to time (this also applies to a situation where two developers are sending their work back and forth through a bare middleman).

    Initialization

    Create some directory on your local computer and cd into it, then execute these commands:

    # initialization
    git init --bare server/.git
    git clone server content
    git clone server local
    
    1. First you create a bare server directory (notice the .git at the end). This directory will serve as a container for your repository files only.
    2. Then clone your server repository to a newly created content directory. This is your live/production directory which will be served by your server software.
    3. The first two directories resides on your server, the third one is a local directory on your workstation.

    Workflow

    Now here is the basic workflow:

    1. Enter the local directory, create some files and commit them. Finally push them to the server:

      # create crazy stuff
      git commit -av
      git push origin master
      
    2. Now enter the content directory and update the server's content:

      git pull
      
    3. Repeat 1-2. Here content may be another developer that can push to the server too, and local as you may pull from him.

提交回复
热议问题