0

Just a beginner in using git and github, i have basic understanding of how it works but there's one thing i am stuck at and can't seem to find the solution.

I made a remote repository on github, cloned it to my local git repository, added a new html file and then pushed it to github.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1>heading 1</h1>
</body>
</html>

Then i added a paragraph tag in the above html file and then pushed it to github

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1>Branching Test 1</h1>
    <p>paragraph 1</p>             <!-- added this-->
</body>
</html>

Now master branch on github contains the html file with the paragraph tag.

Problem

I restored the initial version of html file i.e. without the paragraph tag by using git reset command. Now i want to push this html file on github and replace the html file on master branch with this html file, essentially undoing the change of adding paragraph tag but running git push command throws error that

failed to push
hint: Updates were rejected because the tip of your current branch is behind its remote 
      counterpart 

Question

What is the best way to revert to older version of my project on local git repository and then pushing that version of project to github, replacing the latest version on github with the older version.

0 Answers0