Contents...
Git commit command is sued to save your changes in a local repository. Using git commit command you can add any new file or files and update the existing content of the files.
Note that you need to explicitly let Git know which transforms you need to remember for a submit prior to running the “git commit” order. This implies that a document will not be consequently remembered for the following commit in light of the fact that it was changed. All things being equal, you need to utilize the “git add” order to check the ideal changes for inclusion.
Please note that git commit command is not automatically transferred to the remote server. Using the “git commit” command only saves a new commit object in the local Git repository.
Git Add
First run the git add command to add your in local repository.
# git add .
Note (.) means you are adding all changes/created file in git repository. If you want to single or multiple fine run below command.
Single File:
# git add {filename}
Multiple File:
# git add {filename1} {filename2} {filename3}
Dry run command for git adding will actually not add the file. If you want to test files if they exist and/or will be ignored with git command.
git add . --dry-run
Git Commit
Run the below command to save your changes in a local repository.
# git commit -m "Type or commit msg here"
Output:
# git commit -m "Add/Update PDF Files" 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Documents/1.pdf create mode 100644 Documents/2.pdf create mode 100644 README.md
Options:
-m <message>
Sets the commit’s message. Make sure to provide a concise description that helps your teammates (and yourself) understand what happened.
-a
Includes all currently changed files in this commit. Keep in mind, however, that untracked (new) files are not included.
–amend
Rewrites the very last commit with any currently staged changes and/or a new commit message. Git will rewrite the last commit and effectively replace it with the amended one. Note that such a rewriting of commits should only be performed on commits that have not been pushed to a remote repository, yet.
# git commit -a -m "Add/Update PDF Files" 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Documents/file1.pdf create mode 100644 index.html
Now your files has successfully committed to the current working directory. You can check git logs before push this files to the remote repository.
# git log commit 86da8f0be29dd6d1f9ce3913be4f353fc4ecb9fb Author: Santosh Prasad Date: Sat Mar 14 10:09:24 2018 +0000 Updated Documents commit 7b480fe93bd9ed5deb9da2da3d709e8370056a7f Author: Santosh Date: Sat Mar 14 10:01:24 2018 +0000 Updated Documents
Once you’re ready to push your commits to the remote repository (origin), you’ll need to use the ‘push’ command:
# git push origin master
You successfully push your changes to master branch.
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment