Can I versioning A Word document in Git
I would like to do a Test in Git by versioning Any Word document for example:
- Enter any line and commit
- Enter another line and commit
- Go back from Version 2 to Version 1 and check the word document if it is as in the first step.
1 answers
I will make an example for you to understand:
1) Create any folder for versioning;
2) inside this folder, start Git :
git init
Initialized empty Git repository in [
caminho da pasta
]/.git /
3) Create a file in word and save in this folder:
4) See the git status :
git status
On branch master
No commits yet
Untracked files: (use " git add ..."to include in what will be committed)
documento-word-2013.docx ~$cumento-word-2013.docx
Nothing added to commit but untracked files present (use "git add" to track)
5) make the first commit :
git add .
git commit -m "Documento criado"
6) make a change to the Word file and save:
7) make the second commit :
git add .
git commit -m "Adicionado segundo texto lorem"
8) See list of commits :
git log
Commit 97ccced5fc1f03bf8a4c1747be6915039f384c9c (HEAD - > master)
Author: lipespry
Date: Thu Jan 10 04:59:49 2019 -0200
Adicionado segundo texto lorem
Commit 2e5e1914988c4aab4d83e57aa0b59254da4fbe18
Author: lipespry
Date: Thu Jan 10 04:58:12 2019 -0200
Documento criado
9) back to first snapshot :
git checkout 2e5e1914988c4aab4d83e57aa0b59254da4fbe18
Note :checking out '2e5e1914988c4aab4d83e57aa0b59254da4fbe18'.
You are in' detached HEAD ' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using-b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 2e5e191 document created
10) open the file and check how it is:
@edit (thanks to Jefferson Quesado):
It's a shame, but Git doesn't detail changes to Word documents (git diff
). At least not natively.