- Start working on your project
- Working with files on the command line
- Sample Git task flow
When working with Git from the command line, you need to use more than just the Git commands. There are several basic commands that you should learn, in order to make full use of the command line.
To work on a Git project locally (from your own computer), with the command line, first you need to clone (copy) it to your computer.
This section has examples of some basic shell commands that you might find useful. For more information, search the web for bash commands.
Alternatively, you can edit files using your choice of editor (IDE), or the GitLab user interface (not locally).
The list below is not exhaustive, but contains many of the most commonly used commands.
|Go into a directory to work in it|
|Go back one directory|
|List what’s in the current directory|
|List what’s in the current directory that starts with |
|List what’s in the current directory that ends with |
|Create a new directory|
|Display the contents of a text file you created previously|
|Show the current directory|
|Clear the shell window|
To create a text file from the command line, for example
README.md, follow these
touch README.md nano README.md #### ADD YOUR INFORMATION #### Press: control + X #### Type: Y #### Press: enter
It’s easy to delete (remove) a file or directory, but be careful:
rm -r NAME-OF-DIRECTORY
You can view the history of all the commands you executed from the command line, and then execute any of them again, if needed.
First, list the commands you executed previously:
Then, choose a command from the list and check the number next to the command (
for example) . Execute the same full command with:
Not all commands can be executed from a basic user account on a computer, you may
need administrator’s rights to execute commands that affect the system, or try to access
protected data, for example. You can use
sudo to execute these commands, but you
might be asked for an administrator password.
sudo. Certain commands may cause damage to your data or system.
If you’re completely new to Git, looking through some sample task flows may help you understand the best practices for using these commands as you work.