If we make a change to a file and then try to change branches we get this
santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git checkout master
error: You have local changes to 'Max_LCD.cpp'; cannot switch branches.
So what we do is run git stash, which tucks things away onto a local stack
santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git stash
Saved working directory and index state "WIP on dev: 0209cfa... changed MAX3421E to Max3421e for case sensitive compilers"
HEAD is now at 0209cfa changed MAX3421E to Max3421e for case sensitive compilers
(To restore them type "git stash apply")
santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git checkout master
Switched to branch "master"
//inspect changes, now I need to switch back
santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git checkout dev
Switched to branch "dev"
santiago@santiago-desktop:~/arduino-0016/hardware/libraries/USB_Host_Shield$ git stash pop
# On branch dev
# Changed but not updated:
# (use "git add
#
# modified: Max_LCD.cpp
#
# Untracked files:
# (use "git add
#
# Max3421e.o
# Max_LCD.cpp~
# Max_LCD.o
# Usb.h~
# Usb.o
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (da0cd6de12e2128986ffdfe053f0c81cb5b264b3)
This makes a complicated situation much easier!
No comments:
Post a Comment