Getting Started Flashcards

Still on "Undoing changes"

1
Q

Create a new repository in the current directory

A

git init

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Create an empty repository in a new directory

A

git init

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Initialize an empty Git repository in a new folder, but omit the working directory.

A

git init –bare

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Clone a specific git repository to the current directory

A

git clone

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Clone a specific git repository to a specified local directory

A

git clone

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define the author name to be used for all commits in the current repository

A

git config –global user.name

Typically, you’ll want to use the –global flag to set configuration options for the current user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define the author email to be used for all commits by the current user.

A

git config –global user.email

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Create a shortcut for a Git command.

A

git config –global alias.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define the text editor used by commands like git commit for all users on the current machine

A

git config –system core.editor

The argument should be the command that launches the desired editor (e.g., vi).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Open the global configuration file in a text editor for manual editing

A

git config –global –edit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Stage all changes in for the next commit.

A

git add

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Stage all changes in for the next commit.

A

git add

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Begin an interactive staging session that lets you choose portions of a file to add to the next commit.

A

git add -p

This will present you with a chunk of changes and prompt you for a command. Use y to stage the chunk, n to ignore the chunk, s to split it into smaller chunks, e to manually edit the chunk, and q to exit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Create an initial commit of the current directory

A

git add .

git commit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Add a file to the repository and commit the addition

A

git add hello.py

git commit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Commit the staged snapshot

A

git commit

This will launch a text editor prompting you for a commit message. After you’ve entered a message, save the file and close the editor to create the actual commit. git commit -m “”

17
Q

Commit a snapshot of all changes in the working directory only including modifications to tracked files (those that have been added with git add at some point in their history)

A

git commit -a

18
Q

Return to the master branch

A

git checkout master

19
Q

Check out a previous version of a file

A

git checkout

This turns the that resides in the working directory into an exact copy of the one from and adds it to the staging area.

20
Q

git checkout

A

git checkout

Update all files in the working directory to match the specified commit. You can use either a commit hash or a tag as the argument. This will put you in a detached HEAD state

21
Q

Get a list of the previous commits (with one line descriptions)

A

git log –oneline

22
Q

Checkout a single of a commit

A

git checkout

23
Q

Undo a committed snapshot.

A

git revert

Instead of removing the commit from the project history, it figures out how to undo the changes introduced by the commit and appends a new commit with the resulting content. This prevents Git from losing history, which is important for the integrity of your revision history and for reliable collaboration