#git-basics-vscode
#assembler-institute
#master-in-software-development
With these exercises you will learn how to use git in your VSCode interface.
Git is a version control software designed by Linus Torvalds, thinking about the efficiency and reliability of maintaining application versions when they have a large number of source code files. Its purpose is to keep track of changes in computer files and coordinate the work that several people do on shared files.
- Learn how to work with Git using the integrated VSCode Git plugin
In this pill you will learn how to use the integrated VSCode Git plugin to work with Git to perform the most common operations such as creating commits or working with branches.
Next, you will need to follow the instructions to complete the exercises:
1.2.0 Clone the repository to create a local copy on your computer:
https://github.com/assembler-school/git-basics-vscode.git
- Execute in the terminal the following command to install the necessary programs for the pill:
npm install
- Once the command is finished you can continue with the exercises
1.2.1 exercise-01: Create a new file and add it to the staging area
- Create a new file named:
exercise-01.txt
inside thesrc/exercises
folder - Add any text value inside the new file and save the new file
- Add the file to the staging index with the Git plugin
- Execute the:
npm run validate-exercise-01
command from the terminal to validate your solution to the exercise
1.2.2 exercise-02: Create a commit with the new file
- Create a new commit based on the changes in the staging area that have the new file you just created
- Use a commit message of:
'commit exercise-02'
- Execute the:
npm run validate-exercise-02
command from the terminal to validate your solution to the exercise
1.2.3-a exercise-03-a: Create 2 new files and add all of them to the staging area
- Create 2 new files inside the src/exercises folder with the names of:
exercise-03-a.txt
exercise-03-b.txt
- Add any text value inside each file and save them
- Add all of them to the staging area with the Git plugin
- Execute the:
npm run validate-exercise-03-a
command from the terminal to validate your solution to the exercise
1.2.3-b exercise-03-b: Create a new commit with the new files
- Create a commit with all the new files with the commit message of:
'commit exercise-03'
- Execute the:
npm run validate-exercise-03-b
command from the terminal to validate your solution to the exercise
1.2.4-a exercise-04-a: Make a change and add it to the staging index
- Change the content of the
exercise-03-a.txt
file and add the changes to the staging index with the Git plugin - Execute the:
npm run validate-exercise-04-a
command from the terminal to validate your solution to the exercise
1.2.4-b exercise-04-b: Use the git plugin to unstage the changes
- Use the git plugin to unstage the changes from the staging index
- Now you should see that the changes were added back to the working directory and out of the staging index
- Execute the:
npm run validate-exercise-04-b
command from the terminal to validate your solution to the exercise
1.2.5 exercise-05: Use the git plugin to discard all the changes made to a file
- Use the git plugin to discard all the changes made to the file so that the working directory is cleaned using the Discard All Changes option
- This command will remove all the changes you made to the file and they will be deleted. This is useful if you don’t want to keep the changes that you made so far.
- NOTE: This command removes the changes, you will not be able to recover them once they are removed.
- Execute the:
npm run validate-exercise-05
command from the terminal to validate your solution to the exercise
1.3.1 exercise-06: Create a new branch named develop and make a commit
- Use the Git plugin to create a new branch named
develop
using theCheckout to
option and then theCreate new branch
option to create a new branch - This command will create a new branch and switch from the current branch to it afterwards
- Create a new file named
exercise-06.txt
in the thesrc/exercises
folder that has any value inside and create a new commit with the new file with any commit message
- Execute the:
npm run validate-exercise-06
command from the terminal to validate your solution to the exercise
1.4.2 exercise-07: Switch back to the master branch
- Use the Git plugin to switch back to the
master
branch - Execute the:
npm run validate-exercise-07
command from the terminal to validate your solution to the exercise
1.4.3 exercise-08: Use the git plugin to push the repository to the GitHub platform
- Create a new empty repository in the GitHub platform and copy the origin URL
- Copy the URL from the
git remote add origin https://...
step that says...or push an existing repository from the command...
- Open the VSCode Command Palette with CMD + SHIFT + P (MAC) or CTRL + SHIFT + P (WIN) and type Git Remote and choose the Git Remote Remove option to remove the current remote of the repository.
- You can execute the following command in the terminal to see a list of the current remote URLs in your local repository to see if it was removed:
git remote -v
- Open the VSCode Command Palette again and add the remote repository URL from the GitHub platform as the new origin of your local repository
- Type the following in the Command Palette to add a new remote repository URL:
Set the remote repository name, usually it is origin:
Set the remote origin URL for the origin remote repository URL:
- Open the VSCode Command Palette again and type git push to upload the local repository to the remote repository
- Then, you will be asked if you want to set the remote repository URL as tracking so that all the following GIT Pull/Fetch operations are made with this URL. (choose yes/ok)
- Next, you will have to enter your username and password:
- Execute the:
npm run validate-exercise-08
command from the terminal to validate your solution to the exercise
Now your local repository should be published in Github.
1.4.1 exercise-09: Create a new stash entry without a message
- Change the contents of the
exercise-03-a.txt
file and save the file - Use the GIT plugin to create a new stash entry without a message using the
Stash
option - This command will create a new stash entry with the changes that you made to the file.
- Then you can use the
git stash list
command to see a list of all the stash entries that you made, or the thegit stash show stash@{0}
command to see the files that were affected by the stash entry number 0 - Stash entries are 0 indexed like arrays
- If you’d like to see the changes made in the stash you can use the following command to see the code changes in the stash entry:
git stash show --patch stash@{0}
- Execute the:
npm run validate-exercise-09
command from the terminal to validate your solution to the exercise
1.4.2 exercise-10: Remove the stash entry and apply the changes again
- Use the GIT plugin and the
Pop Latest Stash
option to remove the stash entry from the stash and apply the changes to the working directory - This command will remove the latest stash entry from the stash and apply the changes in the working directory.
- Execute the:
npm run validate-exercise-10
command from the terminal to validate your solution to the exercise
1.3.3 exercise-11: Create a new stash entry with a message
- Create a new stash entry with the changes made to the
exercise-03-a.txt
file from the previous steps - Use the GIT plugin command to create a new entry that has a stash message of:
'my stash message'
- This will create a new stash entry like the exercise-09 but one that has message that you define
- Execute the:
npm run validate-exercise-11
command from the terminal to validate your solution to the exercise
1.3.4 exercise-12: Clear the stash list
- Run the GIT command in the VSCode terminal to remove all the stash entries from the stash
git stash clear
- This will remove all the stash entries from the stash
- Execute the:
npm run validate-exercise-12
command from the terminal to validate your solution to the exercise
1.3.5 exercise-13: Create a new file and store it in a stash entry
- Create a new file named
exercise-13.txt
in thesrc/exercises
folder and store any text value inside - Use the GIT plugin and the
Stash Include Untracked
option to create a new stash entry that also stashes files that are not tracked by GIT with a stash message of:'stash with untracked files'
- Execute the:
npm run validate-exercise-13
command from the terminal to validate your solution to the exercise
- You must perform all the steps using only the VSCode Git plugin and only the ones that are specified to be run with the terminal should be done with the terminal
- You must create a new repository to upload the finished exercises
The following deliverables will be necessary to evaluate the project:
- The repo uploaded to a Github repository with the solutions to the exercises