How do i unstage a file on my git repository?



  • man page git reset: http://bit.ly/2oG1v6V

    If you accidentally stage a file ready for commit and want to unstage it, remember this is before you have committed.

    You have added a new file and can see it has been staged, the last message says unstage and git provides pointers along the way, it tells you how to unstage the file.

    $ vi themenight.php
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
    	themenight.php
    
    nothing added to commit but untracked files present (use "git add" to track)
    $ git add themenight.php 
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
    	new file:   themenight.php
    

    Unstage the file After the unstage git shows it as untracked.

    $ git reset HEAD themenight.php
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
    	themenight.php
    
    nothing added to commit but untracked files present (use "git add" to track)
    

Log in to reply
 

© Lightnetics 2024