Jupyter Snippet CB2nd 04_git_advanced

Jupyter Snippet CB2nd 04_git_advanced

2.4. A typical workflow with Git branching

pwd
/home/cyrille/git/cookbook-2nd/chapter02
cd myproject
git branch newidea
git branch
* master
  newidea
git checkout newidea
Switched to branch 'newidea'
git branch
  master
* newidea
echo "print('new')" > newfile.py
cat newfile.py
print('new')
git add newfile.py
git commit -m "Testing new idea"
[newidea 8ebee32] Testing new idea
 1 file changed, 1 insertion(+)
 create mode 100644 newfile.py
ls
file.txt  newfile.py
git checkout master
Switched to branch 'master'
ls
file.txt
git merge newidea
Updating 045df6a..8ebee32
Fast-forward
 newfile.py | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 newfile.py
ls
file.txt  newfile.py
git reset --hard HEAD~1
HEAD is now at 045df6 Add exclamation mark to file.txt
git branch
* master
  new idea
git branch -D newidea
Deleted branch newidea (was 8ebee32).
ls
file.txt
echo "new line" >> file.txt
cat file.txt
Hello world!
new line
git stash
Saved working directory and index state WIP on master:
045df6a Add exclamation mark to file.txt
HEAD is now at 045df6 Add exclamation mark to file.txt
cat file.txt
Hello world!
git stash pop
On branch master
Changes not staged for commit:

    modified:   file.txt

no changes added to commit
    (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (c9071a)
cat file.txt
Hello world!
new line