# Common Git workflows

Git is a powerful tool, but it can be quite confusing. There are a lot of commands to remember, and resolving conflicts is just a complicated concept in general. In this exercise, you'll learn the most common and easiest to use workflow for Git within VS Code.

{% tabs %}
{% tab title="Exercise" %}

* Modify both of the meta tag descriptions in the "index.html" file&#x20;
* Stage both files
* Commit both files
* Push changes to Github
  {% endtab %}

{% tab title="Answer" %}

* Open the "index.html" file

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7NHG2V0GOTUvTCMSv%2Fimage.png?alt=media\&token=d1d5da23-ab73-4413-9ca5-13e124b4bc1d)

* Highlight "I LOVE LAMP" on line 7 and press **Cmd/Ctrl + D** to add a cursor to the second instance on the line below.

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7NV-mQ39BhFoh7ti6%2Fimage.png?alt=media\&token=ca583a1a-ced9-4211-b11b-8c5ea7437b36)

* Change the value to "I love lamp"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7NfzTpPQICw1HrUrV%2Fimage.png?alt=media\&token=756fd865-aa3e-42e7-9edc-085b2373313d)

* Open the Source Control Explorer view (**Ctrl + Shift + G**)
* Click the "+" button next to the "index.html" file to stage it

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7OFk4Tun0q2EGU89p%2Fimage.png?alt=media\&token=f675a465-f59d-4066-b2a5-032156772eab)

* Add a message to the "Message" box and press **Cmd/Ctrl + Enter**

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7OUYIQAiGmxVSFgOs%2Fimage.png?alt=media\&token=2aa2d10f-a57a-404a-8651-c5482d0d5e2d)

* Undo the commit by pressing the ellipsis in the top right corner and select "Undo Last Commit"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7OoTBL9U8QTR8kOAV%2Fimage.png?alt=media\&token=427ba6e2-63e0-427f-bdef-b781cac81b63)

* Change the commit message to "Better description"
* Press **Cmd/Ctrl + Enter** to commit&#x20;
* Use the button the bottom status bar to push changes to your repo

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7LJlnCld0z39JcA-0%2F-Lm7PKTOQrP29DrIWA7N%2Fimage.png?alt=media\&token=4cbfabec-a2cf-40f2-b315-505507362b6f)

* Open the Settings file (**Cmd/Ctrl + ,**)
* Add the following line so that VS Code can automatically tell you how many commits you are ahead of or behind the repo.

```
"git.autofetch": true
```

{% endtab %}
{% endtabs %}
