git Basic Commands Summary 2
pwd: current foldercd: move directorycd..: move to parent folder
Autocompletion: available with tab key
ls -al
git init
git remote add <원격저장소이름>
ls -alView hidden folders, hidden filesgit initCreate local repositorygit remote add <address>Informs the master folder on my computer of the GitHub repository address.
- master: branch name
- origin: remote repository name
git log - Check history #
git log [option] [revision range] [[--] <path>..]
git logis a feature that allows you to output logs in the desired format by combining various options.
git reset - To previous state (remove history) #
git reset [<commit>] [--soft | --mixed [-N] | --hard | --merge | --keep]
Resets the history up to a specific commit. You can undo work done just before, or up to n commits ago.
Use with caution as history will be erasedgit resethas various options, but here we will use the--hardoption.
Task #
- Check commit ID for commit #2 with
git log - Reset history up to commit #2
git log
git reset {v2 커밋 아이디} -- hard # 커밋 아이디 예) 27a00b7
- result:
HEAD is now at 27a00b7 v2 commit
- Reset history up to commit #2 -> Confirms deletion of commit #3 history.
Current Git repository history
