create version(editing history)

2023-03-18 hit count image

we should create the version(editing history) to manage source code on git repository. we introduce how to create version(editing history).


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.

git status
  • 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.

git status after executing git add command
  • Changes to be committed: next version(editing history) file list. we added new file so we can see text.txt with new 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.

git commit

this screen is vim that is a text editor. we need to push i(insert) for editing the document. and type messages about changes.

git commit with message

when you finish to write messages, push esc button on the keyboard and type :wq(write-quit) and pusy enter button for saving.

git completed commit

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.

git log
  • 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.

git status no change

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

git status with modification
  • 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.

git status after commit

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
git log with new version

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


we saw about how to create version(editing history). the summary is as below.

  1. cretae or edit files.
  2. check created or added files with git status command.
  3. execute git add command to add files to version(editing history).
  4. check registered files well with git status command.
  5. create version(editing history) with messages by git commit command.
  6. check created version(editing history) with git log command.
  7. see the changes with git log -p command
  8. 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

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.