Sei sulla pagina 1di 3

//How to use Command Line

The command line is a text interface for the computer's operating system. To acc
ess the command line, we use the terminal.
A filesystem organizes a computer's files and directories into a tree structure.
It starts with the root directory. Each parent directory can contain more child
directories and files.
From the command line, you can navigate through files and folders on your comput
er:
pwd
outputs the name of the current working directory.
ls
lists all files and directories in the working directory.
cd
switches you into the directory you specify.
mkdir creates a new directory in the working directory.
touch creates a new file inside the working directory.
Options modify
ls -a
rectories
ls -l
ls -t

the behavior of commands:


lists all contents of a directory, including hidden files and di
lists all contents in long format
orders files and directories by the time they were last modified
Multiple options can be used together, like ls -alt

From the command line, you can also copy, move, and remove files and directories
:
cp
copies files
mv
moves and renames files
rm
removes files
rm -r removes directories
*
Wildcards are useful for selecting groups of files and directorie
s

Congratulations! You learned how to use the command line to redirect standard in
put and standard output. What can we generalize so far?
Redirection reroutes standard input, standard output, and standard error.
The common redirection commands are:
>
redirects
ious content.
>>
redirects
ntent to old content.
<
redirects
|
redirects

standard output of a command to a file, overwriting prev


standard output of a command to a file, appending new co
standard input to a command.
standard output of a command to another command.

A number of other commands are powerful when combined with redirection command
s:
sort:
uniq:
grep:
sed :

sorts lines of text alphabetically.


filters duplicate, adjacent lines of text.
searches for a text pattern and outputs it.
searches for a text pattern, modifies it, and outputs it.

//How to Use Git


Learn Git: Use Git commands to help keep track of changes made to a project:
git init
git status
area
git add
git diff
ging area
git commit
epository
git log

creates a new Git repository


inspects the contents of the working directory and staging
adds files from the working directory to the staging area
shows the difference between the working directory and the sta
permanently stores file changes from the staging area in the r
shows a list of all previous commits

How to BackTrack:
Congratulations! You've learned three different ways to backtrack in Git. You ca
n use these skills to undo changes made to your Git project.
git checkout HEAD filename

Discards changes in the working directo

git reset HEAD filename

Unstages file changes in the staging ar

ry.
ea.
git reset SHA
ous commit in your commit history.

Can be used to reset to a previ

Additionally, you learned a way to add multiple files to the staging are
a with a single command:
git add filename_1 filename_2
Git How to Branch:
Git branching allows users to experiment with different versions of a project by
checking out separate branches to work on.
git branch
git branch branchname
git checkout branchname

Lists all a Git project's branches.


Creates a new branch.
Used to switch from current branch to bran

chname.
git merge branchname
to another.
git branch -d branchname

Used to join file changes from one branch


Deletes the branch specified.

Git Teamwork: Pushing and Pulling


A remote: a shared Git repository that allows multiple collaborators to work on
the same Git project from different locations.
Collaborators work on the project independently, and merge changes together when
they are ready to do so.
A remote is a Git repository that lives outside your Git project folder.
Remotes can live on the web, on a shared network or even in a separate folder on
your local computer.
The Git Collaborative Workflow are steps that enable smooth project development

when multiple collaborators are working on the same Git project.


git clone
git remote -v
git fetch
local copy.
git merge origin/master
l branch.
git push origin branchname
emote.

Creates a local copy of a remote.


Lists a Git project's remotes.
Fetches work from the remote into the
Merges 'origin/master' into your loca
Pushes a local branch to the origin r

GitHub's cheatsheet: https://education.github.com/git-cheat-sheet-education.pdf

Potrebbero piacerti anche