git pull one file from remote

10,697

git reset HEAD~ will revert the laster commit of the current branch, but since you have already pushed the branch Li to public, it is better to do a git checkout master task.js and commit again in your branch Li.

Share:
10,697

Related videos on Youtube

user429400
Author by

user429400

Updated on October 18, 2022

Comments

  • user429400
    user429400 over 1 year

    I've cloned a repository "Rep" and created my own local branch "Li". I've committed a file called "task.js" to the local "Li" branch and pushed it to the remote "Li" branch. Now I want to revert this action by:

    1. pulling the original "task.js" from the remote "master" branch to the local "Li" branch
    2. push the reverted "task.js" from the local "Li" branch to the remote "Li" branch.

    I tried to read several "pull" tutorials but can't figure out a way to do this (maybe because I don't really understand the basics yet...)

    Thanks, Li

  • weynhamz
    weynhamz over 11 years
    Due to he his already pushed the Li branch which means this is probably not a good idea.
  • user429400
    user429400 over 11 years
    what does this command do? Does this overrides the local "Li" task.js with the local master task.js? (it worked, I just want to understand what I did)
  • weynhamz
    weynhamz over 11 years
    Yes, git checkout master task.js will simply checkout the task.js of the master branch, for your case, you probably need a -f flag.
  • Mohanraj
    Mohanraj over 11 years
    Oh, ok, so he need to revert that commit.