Making changes in Git

Making changes in Git

The main important feature about git is, git can track file changes. before committing when we need to check the modifications of our code, that does it have any errors or mistakes.we need to check what changes are staged and ready to commit.

Command to check the status

git status
Status of the new repo
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
Status of repo with changes
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: xx.c
Status of repo with no changes
On branch master
nothing to commit, working directory clean

DIFF Keyword in Git

For reviewing our changes before committing we use git diff, this shows the deleted lines and added lines of code

added files are shown by + symbol before lines

deleted lines are shown by – symbol before lines

example: if I changed my email in the info file, the basic git diff command shows the difference between the present working directory and staged files

Making changes in Git

if you observe above in the screenshot, I have changed my mail domain name Gmail to outlook and didn’t add the modified info.txt file

git allows a user to compare between so many things like branches, between commits, we have a separate post for diff commands

Saving changes of files

after modifying files in the working tree, user should commit changes in order to save changes

git commit -m "your commit message"
Last updated on by vishal devxo