Pushing changes to a git repository
You can push local changes to a git repository by first adding files and creating commits.
Once the commits are ready, you can push the commits into remote git repository as shown below.
Check the commit in the local git repository using git log –oneline.
~/repoone$ git log --oneline
453424e (HEAD -> main) This is first commit
2673111 (origin/main, origin/HEAD) Initial commit
Check the contents of the commit using git show.
~/repoone$ git show 453424e
commit 453424edeed5c7c668cf7ce5d9f3b4ccb9aa566e (HEAD -> main)
Author: paperspace <Code Version Master>
Date: Sun Sep 4 17:43:08 2022 +0000
This is first commit
diff --git a/dirone/fileone b/dirone/fileone
new file mode 100644
index 0000000..c2a1599
--- /dev/null
+++ b/dirone/fileone
@@ -0,0 +1 @@
+this is file one
diff --git a/filetwo b/filetwo
new file mode 100644
index 0000000..f8156fa
--- /dev/null
+++ b/filetwo
@@ -0,0 +1 @@
+this is file two
Check the remote branch names for the current repository.
~/repoone$ git remote -vv
origin git@github.com:codeversionmaster/repoone.git (fetch)
origin git@github.com:codeversionmaster/repoone.git (push)
Make sure you are in the right branch.
~/repoone$ git branch
* main
Check the status of the branch using git status to see that you are ahead by a certain number of commits.
~/repoone$ 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
Push the commits with the command git push <remote repository name that links to current repository> <branch name on remote repository>.
~/repoone$ git push origin main
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 397 bytes | 397.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To github.com:codeversionmaster/repoone.git
2673111..453424e main -> main
Check the status of the branch.
~/repoone$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean