Contributing a new project to Github
Welcome to Weiping’s Channel! As a powerful and popular code hosting platform for version control and collaboration, It is widely used in software developing companies and becomes one of the must-have skills for us software engineers.
Here I am going to talk about how to create a new repository in GitHub when starting a new project, and how to update the repository with Git. Here, the new project is a simple task, which is to create a BASH script to add users in the CentOS 8 server. Also I will share the BASH scripts in the end of this post.
Step 1 Create a new repository in Github
Login to?https://github.com?and click the “+” and choose “New repository”. Follow the guideline in the official Github website to create a repo:?https://docs.github.com/en/get-started/quickstart/create-a-repo.
The newly created repo will display on the home page.
Click the repo we just created.
You will see some tips about how to create a local repo in your computer (we call it “local”, compared to the repo in Github, which we called “remote”) on the page like below. Follow the first one “create a new repository…” as this is a new project.
Now we need to create a working directory in our local environment.
The new project is to add a user to the CentOS 8 server. So now I login to a CentOS 8 system and create a working directory “test” under my home directory and create a BASH script usersadd.sh in (please see the details of the script below).
After the work is ready to be pushed to remote in Github where people can see it from the Github website, run the commands on the Github page in the working directory.
Now the files usersadd.sh and README.md created in the local machine are pushed to the remote master branch.
Step 2 Update the repository
Now there is new requirement asking to update the feature of the project that Based on the new requirement that multiple users need to be added to the CenOS 8 system at a time. We need to update the script usersadd.sh to fulfill this requirement. (Please see the details of the script below)
First we check the status of our current branch and make sure it is up to date with the remote one.
Then from the master branch, we create a new branch using
$ git checkout -b <new branch>
After that, we update the BASH script and the README.md in the new branch dev.
After the changes are made and everything is verified working fine, we need to merge the changes back to the local master branch by checking out back to the master branch and merge the dev branch.
$ git checkout master
领英推荐
$ git merge dev
After merging the dev branch into the master branch, use git push to push the changes we just made to the remote master branch in Github.
Check the status of the local master branch again, it is up to date with the remote master branch in Github.
In Github, it shows the updated repo and the commit messages.
Appendix The project requirement and the BASH script
The project require
Run the script:
When the user exists:
When the user does not exist and is ready to be added:
The new requirement after the repo is created:
No new users to be added:
2 new users to be added:
Above is a simple Git project creation and update with BASH scripts about adding new users in a Linux system attach. Hope you enjoy the reading! See you next time.
Cloud DevSecOps Engineer ? Joyful Problem Solver
2 年Great article, Weiping!
Security Analyst @ EWTN
2 年Nice article!
Platform Engineering Leader @ Comcast | Advisor | DevOps | AWS Community Builder | Docker Captain | Cloud Engineering | Cloud Resiliency | Cloud Automation & Security
2 年Looks good!