top of page
dotsincloud

GIT Primer

"How to use Git to Make Changes to Code"


Scenario:

The scenario is that Development is working on an application called "ACME". We are tasked with making a change to the simple "ACME web application". Instead of the application main page header reading "Welcome ACME" the customer wants it to read “Welcome to the world of ACME” This text can be found in the project file views/index.ACME on GitHub.


1. Install git:

sudo yum -y install git


2. Configure the name and email address associated with git:

(This is a one-time configuration)


git config --global user.name "<YOUR NAME>"

git config --global user.email "<YOUR EMAIL>"


3. Create an SSH key (On Linux), using the default settings:


ssh-keygen -t rsa -b 4096

Display the contents of our new public key (be sure to copy the key to your clipboard):


cat /home/cloud_user/.ssh/id_rsa.pub


4. Log in to GitHub, navigate to Settings, click on SSH and GPG keys, and click on New SSH Key. Paste your public key information into this field and then click Add SSH key.


5. Create a Fork

Create a personal fork of the sample repository https://github.com/cicd-pipeline-ACME-git.


6. Navigate to the URL https://github.com/linuxacademy/cicd-pipeline-train-schedule-git

Click Fork in the top-right of the page.

Clone your personal fork from GitHub.


7. Click the green Clone or download button and copy the string that is displayed


8. In your terminal, run the following command:


cd ~ /

git clone git@github.com:<yourGITname>/cicd-pipeline-ACME-git.git

cd cicd-pipeline-ACME-git/


9. Create a feature branch to contain the change:


git checkout -b myBranch


10. Change the header text in views/index.ACME from “"Welcome ACME"” to “Welcome to the world of ACME”:


vim views/index.ACME


11. Add the change in views/index.ACME to the next commit:


git add .


12. Commit the change:


git commit -m "<UNIQUE MESSAGE>"


13. Push the Commit

Push the change to the remote SCM repository:


git config --global push.default simple

git push --set-upstream origin myBranch


14. Create a pull request to merge the feature branch into the master branch:


On the GitHub fork page, click Branches, locate myBranch under Your branches, and click New pull request.

In the top-left of the new pull request, change the base fork dropdown menu to your personal fork.

Click Create pull request

Merge the pull request


15. After a few moments, click the Merge pull request button

Click Confirm merge

The change is pushed.


Conclusion

We have installed Git, created a fork of a file, edited it to fulfill our needs, and pushed the change. Congratulations!

10 views0 comments

Recent Posts

See All

Observability vs Monitoring

Observability is the practice of taking logs, traces, and metrics, and doing something with the data. ✅ Metrics: Collecting time series...

Comments


Post: Blog2_Post
bottom of page