Use Git with existing files and update branch after push

we are currently starting to work with Git and run into some trouble.

Baiscally what i want is to have a Git-Repository that users can push to and pull from.

  • Azure websites deploy specific web project
  • Avoid building /refs/heads/master in TeamCity build job for Github pull requests
  • How do I move my remote git repo to another remote git repo?
  • Unable to connect to GitHub within Eclipse due to SunCertPathBuilderException: certificate not found
  • In git, is there a way to show untracked stashed files without applying the stash?
  • How to handle deployment with git and preprocessing
  • Also this repository should work as Preview Version of the master branch, so we need to have the script files in the repository itself.

    I initiated the repository with “git init test.git”. So it’s not a bare repo.

    Question is how to setup git that it holds the current version of the master branch as real files and i can setup a url to reach the current master branch of the repository.

    When i create a repository and try to push to it i get an error that the current master branch is checked out on the repository and i cant push to it.

    Any ideas?

  • Add ignored file to repo but don't track afterwards
  • github: “Link” a Private Repo to an Organization
  • Making the git repo smaller
  • How can I diff two branches with fugitive?
  • What is little red arrow and no sign in github desktop?
  • Git bash home directory different from Git extension than Git Bash
  • 2 Solutions collect form web for “Use Git with existing files and update branch after push”

    You must not push to a non bare repository! You cannot push to a checked out branch!

    Now given you situation my suggestion is:

    Keep a blessed bare repository! Do all your development on the local, merge/rebase on master and then push to blessed bare.

    You can write the post-receive hook of the blessed bare that it has a code/runs a script that has code to cd into your production repo, and pull from blessed bare.(it will be a fast-forward as you might have resolved conflicts before pushing to blessed bare)

    This way, on every push to ‘blessed bare’, you pull into the production and update the checked out master!

    Hope this solves the problem.

    Happy gitting!

    Based on what you have described, then I think implementing the branching strategy known as GitFlow might work for you.

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