Friday, March 12, 2021

Command 'git status'



1. "git status" to check if files need to be 'added'
    
$ git status

On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
    (use "git add [file]..." to include in what will be committed)
    xyz_book.pdf

nothing added to commit but untracked files present (use "git add" to track)

$ git add -A

2. "git status" to tell if files need to be 'committed'.

$ git status

On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged [file]..." to unstage)
	new file:   xyz_book.pdf 

$ git commit -m "cmt"
[main d...0] cmt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 xyz_book.pdf

3. "git status" to tell if files need to be 'pushed'.

$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
    (use "git push" to publish your local commits)

nothing to commit, working tree clean

4. Finally, the "git push" 

$ git push

Username for...
Password for...
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 5.05 MiB | 54.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To ...
    f...0  main -> main

$ git push
Username for 'https://github.com': ^C

$ uname -a
Linux master 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ uname
Linux

Note: On our system, it is not automatically saving the credentials.
Tags: Technology,GitHub,

No comments:

Post a Comment