Outline
we introduced how to create git repository in the previous blog post.(create Repository) in here, we will show how to create version(editing history) to use git version control.
Add new file
copy or create new file on the folder(temp_test_git
) which has git repository.
we created text.txt
file written test text
in temp_test_git
folder for testing.
git status
execute git status
command for checking current status of git repository.
git status
you can see below screen after executing git status
command.
- On branch master: current Branch is Master branch. we will introduce git Branch at another blog post.
- No commits yet: our status is before committing. commit means version(editing history). No commits yet means we didn’t create version(editing history).
- Untracked files: the list of not managing files by git.
we didn’t mention it to git that we want to manage test.txt
file to version(editing history). so we can see test.txt
file with Untracked files
.
git add
we need to tell git that new file(test.txt
) is version(editing history) management target. execute git add
command for helping git recognize new file(test.txt
) is version(editing history) management target.
# add single file
git add test.txt
# add multiple files
# git add test.txt test2.txt test3.txt
# add all files
# git add .
execute git status
command for checking that git recognized new file well.
git status
after executing git status
command, you can see different screen before.
- Changes to be committed: next version(editing history) file list. we added new file so we can see
text.txt
withnew file
.
the reason of existing adding file process by git add
command is that files is existed that we don’t want to include in version(editing history) when we develop real products. for example, it is used to distinguish between the version (history of change) and irrelevant contents like result files after building, DB information files, ID/PW configuration files or temporally edited files for logging with log code(console.log / print, etc)
git commit
we informed git with git add
command which file we want to add to the version(editing history). but version(editing history) is not managed yet. just we told git that we have new files. now, we create version(editing history) by executing git commit
.
git commit
when you execute git commit
command, you can see the create version(editing history) screen.
this screen is vim
that is a text editor. we need to push i
(insert) for editing the document. and type messages about changes.
when you finish to write messages, push esc
button on the keyboard and type :wq
(write-quit) and pusy enter
button for saving.
you can see above messages when you finish to write change history.
git log
execute git log
to check version(editing history) created well.
git log
after executing git log
, you can see current version(editing history) you wrote.
- Author: version(editing history) creator’s name and email(we registered before with
git config
command.) - Date: version(editing history) create date.
- you can see messages you wrote when you executed
git commit
command under the Date section.
If modify files
if files are modified, use the same process as above. execute git status
command to check current status like below.
git status
git tells us there are no changes because we did not do anything.
now we change test text
to test string
in test.txt
file and execute git status
again.
git status
we have changed the file so we can see different screen before
- modified: modified file list.
tell git that we have change history with git add
command. in other words, add the file to version(editing history).
git add test.txt
execute git status
again to check the status.
we can see differences that text color was changed green and no changes added to commit (use "git add" and/or "git commit -a")
message was alos gone. now we can know test.txt
file added to git version(editing history) well. create version(editing history) to use git commit
command. write edit 'text' to 'string'
to version message(editing history message).
git commit
and then execute git log
to check version(editing history) created well.
git log
we can see version(editing history) created well as above.
Check changes
You can see the changes by executing the following command.
git log -p
Also, you can get the Commit
ID by executing the git log
and execute the command below to check the changes.
git diff 'commit id' 'commit id2'
If you execute the following command, you can see the changes of the files before git add
and after git add
.
git diff
Summary
we saw about how to create version(editing history). the summary is as below.
- cretae or edit files.
- check created or added files with
git status
command. - execute
git add
command to add files to version(editing history). - check registered files well with
git status
command. - create version(editing history) with messages by
git commit
command. - check created version(editing history) with
git log
command. - see the changes with
git log -p
command - see the changes with
git diff
command
we can make new version(editing history) as above.
Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!
App promotion
Deku
.Deku
created the applications with Flutter.If you have interested, please try to download them for free.