git add, commit
Using git in working directory
git init
Creating versions by adding and committing
git add filenamegit add filename1 filename2git add .git statusgit restore --staged filenamegit commit -m 'write commit message'# Show as text # After entering, if Vim editor opens, you can scroll up/down with j, k keys, and exit with q key git log# Show as graph # After entering, if Vim editor opens, you can scroll up/down with j, k keys, and exit with q key git log --graph# [Method 1] Cancel commit and preserve files in staged state in working directory git reset --soft HEAD^ # [Method 2] Cancel commit and preserve files in unstaged state in working directory # Default option git reset --mixed HEAD^ # Same as above git reset HEAD^ # Cancel last 2 commits git reset HEAD~2 # [Method 3] Cancel commit and delete files from working directory in unstaged state git reset --hard HEAD^ git-cancel.html
Last updated