staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: README # no changes added to commit (use "git add" and/or "git commit -a") What's the difference between index and working directory
be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: snakepit/__init__.py # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # snakepit/reptile.py
--- i/README +++ w/README @@ -3,4 +3,4 @@ Please read this. However, ignore this line, as this talks about something you don't really gain anything by reading it. -And you know, mice are the coolest animals in the world. +And you know, honey badgers are the coolest animals in the world. Do removals, modifications and untracked files. Compare output of status and short status. Add something in the index, see how diff --cached works
100644 --- i/README +++ w/README @@ -3,4 +3,4 @@ Please read this. However, ignore this line, as this talks about something you don't really gain anything by reading it. And you know, [-mice-]{+honey badgers+} are the coolest animals in the world.
and set up # tracking $ git checkout -b conflict origin/conflict # Same as above $ git checkout -t conflict # Same as above $ git checkout -b conflict # Just create a local branch called conflict
origin and create it, if it does # not exist $ git push origin master:new-master # Push master to remote branch new-master $ git push origin :master # Delete remote branch master $ git push origin +master # Force push master to origin overwriting the remote # information about master branch
# nothing - do not push anything. # matching - push all matching branches. All branches # having the same name in both ends are considered to # be matching. This is the default. # upstream - push the current branch to its upstream # branch. # tracking - deprecated synonym for upstream. # current - push the current branch to a branch of the # same name.
version of file $ git checkout --theirs INSTRUCTIONS # Their version of the file (MERGE_HEAD) $ git checkout -m INSTRUCTIONS # Check out the merge conflict version
INSTRUCTIONS index 63c473b,8cf737a..0000000 --- i/INSTRUCTIONS +++ w/INSTRUCTIONS @@@ -1,1 -1,1 +1,7 @@@ ++<<<<<<< ours +There are important ones ++||||||| base ++There are some ++======= + There is none! ++>>>>>>> theirs
diff Investigate with git log --merge Try checking out different versions of file and reset with git checkout -m Try git checkout --conflict=diff3 Solve the merge
8e10e9b There are some important instructions # Rebase e9a922e..8e10e9b onto e9a922e # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. #
terrario 250cfb0 HEAD@{1}: checkout: moving from terrario to master 250ed94 HEAD@{2}: checkout: moving from master to terrario 250cfb0 HEAD@{3}: commit: Add line to README. ad11e8c HEAD@{4}: reset: moving to HEAD~ b387bb7 HEAD@{5}: commit: Add line to README ad11e8c HEAD@{6}: clone: from [email protected]: nailor/git-training.git
stash save 'def for later' Saved working directory and index state On master: def for later HEAD is now at ad11e8c Honeybadger here. $ git stash list stash@{0}: On master: def for later $ git stash show stash@{0} snakepit/reptile.py | 4 ++++ 1 file changed, 4 insertions(+)