Wednesday, 10 May 2017

GIT, commit and push or discard your changes

Commit and Push

  
Commit your work locally:

 git add file1
 git add file2

 git commit -m "change 2 files"

Or:

 git commit file3 "change 1 file"

Push your work upstream

 [git rebase -i]  #It will allow you to [e]dit, [f]ix and [s]quash the commits since your last push
 git push [--all] [$BRANCH]

Discard your changes

To discard a single file:
    git checkout -- emitter.py

Could be also
    git checkout emitter.py

To remove a change from stash:
    git drop <reference>

To discard all changes (be careful, not tested!)
    git reset [--hard] !!!!

To reset a staged file to be unstaged but without losing your changes:
    git reset HEAD <filename>


To reset already committed files to go back to a previous commit or tag (changes not lost, just become local unstaged changes)
    git reset origin/HEAD

Recover a branch while overwriting local changes
    git checkout -f development
or
    git checkout -- your_filename.src

No comments:

Post a Comment