Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:14:09+00:00 2026-05-24T20:14:09+00:00

I am new to GIT and face scenario as follow: push file below: index.php

  • 0

I am new to GIT and face scenario as follow:

push file below:

index.php

$name = "steve";

echo("good morning");
echo($name);

pull the file and then remove the $name variable by accidentally.

echo("good morning");
echo($name);

Without realizing it, pull and push the new code to server. Problem is the code is broke and no longer working, GIT won’t prompt for removal of the line. Is there anyway to solve such scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:14:11+00:00Added an answer on May 24, 2026 at 8:14 pm

    To be able to handle this, Git would need to have a knowledge of the content that you’re pusing. In your case, Git would have to know that removing $name = "steve"; in a .php file would produce an error.

    But this could be perfectly fine for plain .txt file where you’re just writing text.

    Not the pull overrides the previous code but you did. You removed the line, you told Git to commit that version, you pulled that version from the remote repo. And all that went good.

    The best way to solve such a scenario is avoiding it by testing your code before pushing.


    If that scenario occurs in spite of careful testing, you could of course use Git to restore the last version that was checked in and working using

    git checkout <SHA-HASH> -- index.php
    

    where <SHA-HASH> is the commit-ID of the last good version of index.php.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to git. I wanted to create a repository named Common-Lib, below
I'm using git on a new git linux computer. When I do git push
Is there a way to determine the new git sha of a file (or
Setting up new git installations. On one Windows laptop, I'm running (under cygwin): git
I'm trying to move an existing project into a new git repo So far
I am very new to git. I have a .gitignore in the my working
I am new to git and trying to grasp the ins and outs of
I'm somewhat new to Git. So I've got the origin/master and origin/upbranch on my
I am new to git and if this ques is simple then please bear
I am new to Git and I seem to have one branch too many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.