Table of Contents
Make Changes in Git is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.
Jerry creates a copy of the repository on his machine and decides to perform basic operations. So he created the file string.c. After adding content, string.c will look like this:
#include int my_strlen ( char * s ) { char * p = s ; while (* p ) ++ p ; return ( p - s ); } int main ( void ) { int i ; char * s [] = { "Git tutorials" , "Tutorials Point" }; for ( i = 0 ; i < 2 ; ++ i ) printf ( "string lenght of %s = %dn" , s [ i ], my_strlen ( s [ i ])); return 0 ; }
He compiles and checks his code and everything works normally. Now he can add these changes to the repository safely.
Git adds active files to the staging area.
[jerry @ CentOS project] $ git status -s ?? string ?? string.c [jerry @ CentOS project] $ git add string.c
Git is pointing a bookmark question before naming the file. Obviously these files are not part of Git, and that's why Git doesn't know what to do with these files. That's why, Git is pointing a bookmark question before naming the file.
Jerry has added files to the staging area, the git status command will show the files in this area.
[jerry @ CentOS project] $ git status -s A string.c ?? string
To commit the changes, he uses the git commit command followed by the -m option. If we forget the -m option. Git will open a text editor, where we can write multiple commit information.
[jerry @ CentOS project] $ git commit -m 'Implemented my_strlen function'
The above command will produce the result:
[master cbe1249] Implemented my_strlen function 1 files changed, 24 insertions (+), 0 deletions (-) create mode 100644 string.c
After committing to view the log details, he ran the git log command. It will display the information of all commits with deposit IDs, depositors, commit dates and SHA-1 hash of deposit.
[jerry @ CentOS project] $ git log
The above command will produce the result:
commit cbe1249b140dad24b2c35b15cc7e26a6f02d2277 Author: Jerry MouseDate: Wed Sep 11 08:05:26 2013 +0530 Implemented my_strlen function commit 19ae20683fc460db7d127cf201a1429523b0e319 Author: Tom Cat Date: Wed Sep 11 07:32:56 2013 +0530 Initial commit
FAQ
What is Make Changes in Git?
Jerry creates a copy of the repository on his machine and decides to perform basic operations.
Why is Make Changes in Git important?
A clear understanding of Make Changes in Git helps you make informed decisions, avoid common mistakes, and use the relevant tools or techniques more effectively.
How should beginners approach Make Changes in Git?
Start with the fundamental concepts, follow the examples step by step, and test each change in a safe environment before applying it to important systems or data.
Reader Comments 0
Sign in with email or Google to join the discussion.