How to prevent Merge and Commit for particular branch in Git ??

STEP 1 : Go to your repository in git

STEP 2: Create file .git/hooks/pre-commit with following content:


branch="$(git rev-parse --abbrev-ref HEAD)"

if [ "$branch" = "master" ]; then
  echo "You can't commit directly to master branch"
  exit 1

STEP 3: Make it executable (not required on Windows):

$ chmod +x .git/hooks/pre-commit

To disable fast-forward merges you must also add following option to your .git/config file:

[branch "master"]
    mergeoptions = --no-ff

Post a Comment


  1. Fantastic!! you are doing good job! I impressed. Many bodies are follow to you and try to some new.. After read your comments I feel; Its very interesting and every guys sahre with you own works. Great!!

    giá vé máy bay từ vietnam đi anh

    cách mua vé máy bay đi mỹ giá rẻ

    vé máy bay giá rẻ đi thái lan nok air

    vé máy bay đi malaysia vietjet

    vé máy bay đi singapore từ đà nẵng

  2. I am browsing the website daily, and get good facts from here all the time... visa required for Turkey, the visa fee depends on how quickly you want to process your application. Here you can read all the details about Turkey visa eligibility rules, visa exemption guidelines, passenger locator form & visa fees. Visit Turkey evisa portal.

  3. Nicely written article. Thank you for this. The international tourist who wish to travel to Kenya should apply for Kenya visa application online. Applying online saves time and provide you the best services where you can check the Kenya visa documents requirement and other information very easily.

  4. What an outstanding post! “I'll be back” (to read more of your content). Thanks…Indian 30 days tourist visa or eTV for India is an online travel authorization. Foriegn travelers whose sole purpose of visiting India is for leisure, sightseeing, religious work or casual travel to visit their friends or relatives can apply for an Indian 30 days tourist visa through the online India visa application system.

  5. Thanks for all you do. I like the website themes and layout, you are posting amazing blogs.... (Overseas Citizenship Of India Services) OCI card application online process. You can apply for an OCI card online and you can read all the info related to OCI(Overseas Citizenship Of India Services) card via the Indian visa website.

  6. Amazing! Thanks for sharing with us... After covid19, the Indian e visas have had some changes done by the Indian government. check out the updates and guidelines before going traveling.