How to push on Git
- Related posts
How to switch Git branch
Refer How to first commit on GitI used to GitLab before, and now I have set up Gitea on my Synology NAS server. š” tip: This post is a simple guide on how to use Git. First of all, I want to manage to branch: * main: Operation * develop: Development when creating
When you develop some project, you must be update remote branch.
So this time, I will teach that how to update on Git.
š” tip: This post is a simple guide on how to use Git.
Local Repository
- Modify your code
- Move to project directory
- Open terminal
- Check to Git status
$ git status
Result:
On branch develop Your branch is up to date with 'origin/develop'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: server.js no changes added to commit (use "git add" and/or "git commit -a")
Add source files(DO NOT ADD ALL FILES)
$ git add YourFile
$ git add YourFile
- Check again
$ git status
Result:
On branch develop Your branch is up to date with 'origin/develop'. Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: server.js
- Commit and add message
$ git commit
Result:
YourMessage # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch develop # Your branch is up to date with 'origin/develop'. # # Changes to be committed: # modified: server.js #
- Save
$ wq
Result:
[develop dddddd2] YourMessage 1 file changed, 1 insertion(+)
- Push to remote branch
$ git push -u origin develop
Result:
Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 18 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 315 bytes | 315.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0) remote: remote: Create a new pull request for 'develop': remote: https://YourGitURL/pulls/new/develop remote: remote: . Processing 1 references remote: Processed 1 references in total To https://YourGitURL.git ddddddd..dddddd2 develop -> develop branch 'develop' set up to track 'origin/develop'
- Check again
$ git status
Result:
On branch develop Your branch is up to date with 'origin/develop'. nothing to commit, working tree clean