Exercises GIT Basics PDF
Exercises GIT Basics PDF
Tasks
Tasks for the GIT Basics section
Dear student!
Good luck!
Task 1
Task: command line
Launch the git bash console. Then check with the appropriate command in what directoryyou currently are.
Next, create a directory named Test in your current location and with the usage of the appropriate
command get into this newly created directory. The next step will be to create a text file named
test_file.txt. The last part of the task is to edit the created file using editor VI - the vi command will do this.
Hint: to enter the file using the VI editor, type in the console: vi filename, and to enter edit mode use the ins
(INSERT) key.
Enter the text "This is just a test" into the file and save the file.
Hint: to exit the edit mode, use the ESC key, and in order to save the file, use the following command :wq
Note: all actions should be performed using only the git bash console.
Task 2
Task: Creating a local repository
Launch the git bash console. Then create a directory named my-first-git-repository in the root directory
and navigate to it. With the appropriate command initialize the current directory as a local git repository. To
which branch were we automatically switched to after repository initialization?
Task 3
Task: Undoing the state of a file
Go to the repository created in the previous task (or create a new one with the appropriate one command).
Then create two files from the git bash: test1.txt, test2.txt - with the appropriate command add the file
test1.txt to the staging area and then try to delete it (everything should bemade from the git bash command
line).
In the next part of the task, add the test2.txt file to the staging area the same way as previously. Then modify
it by adding a line of text inside of it. Use the appropriate command to undo the changes. Finally, try to
delete the file.
Task 4
Task: Change history
In the existing repository create a new file called first-commit.txt - add it to the staging area. Then modify
its content in any way. Try to commit the changes to the file using the appropriate command. In the next
part of the task create another file named next-commit.txt - add it to the staging area then modify its
contents, also, modify the first-commit.txt file and commit all these changes. Try to go back one commit
back. Finally, display the history of changes in the repository (appropriate command in the git bash
console).
Task 5
Task: Creating a remote repository
The task will be to create a remote repository in one of the most popular Git hostings - GitHub.
To do this, visit https://github.com/ . If you don't have an account there yet - create one. The next step will
be setting up a new remote repository: go to the GitHub homepage and use the green button labeled ‘New’ -
you should be redirected to the repository creation page (https://github.com/new ). Here you have to fill in
the field ‘Repository name’ (required) representing the name of the repository - let's denote it as public
(checkbox Public) - confirm changes using the ‘Create repository’ button. The second part of the task will
be cloning the remote repository to our local machine - for this purpose, you have to go to our repository
page on GitHub and use the ‘Clone or download’ button - this way we will copy the address of our
repository. The copied address must then be used in the git bash console, e.g. git clone
copied_repository_address. In this way, we have cloned a remote repository to our local computer.
Task 6
Test the operation: try adding some files with the extension .bat. Commit all changes, then push them to a
remote repository.
Task 7