Shared Flashcard Set

Details

Gail Interview Quizzing SAGE GIT Commands
Computer stuff i dont understand
77
Other
Not Applicable
07/09/2018

Additional Other Flashcards

 


 

Cards

Term
Tell Git who you are
Definition
Configure the author name and email address to be used with your commits.
Note that Git strips some characters (for example trailing periods) from user.name.

git config --global user.name "Sam Smith"
git config --global user.email sam@example.com
Term
Create a new local repository
Definition
git init
Term
Check out a repository: Create a working copy of a local repository
Definition
git clone /path/to/repository
Term
Check out a repository: For a remote server
Definition
git clone username@host:/path/to/repository
Term
Add files: Add one or more files to staging (index)
Definition
git add

git add *
Term
Commit: Commit changes to head (but not yet to the remote repository)
Definition
git commit -m "Commit message"
Term
Commit: Commit any files you've added with git add and any files you've changed since then
Definition
git commit -a
Term
Push
Definition
Send changes to the master branch of your remote repository

git push origin master
Term
Status
Definition
List the files you've changed and those you still need to add or commit

git status
Term
Connect to a remote repository: If you haven't connected your local repository to a remote server, add the server to be able to push to it
Definition
git remote add origin
Term
Connect to a remote repository: List all currently configured remote repositories
Definition
git remote -v
Term
Create a new branch and switch to it
Definition
git checkout -b
Term
Switch from one existing branch to another
Definition
git checkout
Term
List all the branches in your repo, and also tell you what branch you're currently in
Definition
git branch
Term
Branches: Delete the feature branch
Definition
git branch -d
Term
Branches: Push the branch to your remote repository, so others can use it
Definition
git push origin
Term
Branches: Push all branches to your remote repository
Definition
git push --all origin
Term
Branches: Delete a branch on your remote repository
Definition
git push origin :
Term
Fetch and merge changes on the remote server to your working directory
Definition
git pull
Term
\To merge a different branch into your active branch
Definition
git merge
Term
View all the merge conflicts
Definition
git diff
Term
Update from the remote repository: View the conflicts against the base file
Definition
git diff --base
Term
Update from the remote repository: Preview changes, before merging
Definition
git diff
Term
Update from the remote repository: After you have manually resolved any conflicts, you mark the changed file
Definition
git add
Term
Tags: You can use tagging to mark a significant changeset, such as a release
Definition
git tag 1.0.0
Term
Tags: CommitId is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using
Definition
git log
Term
Tags: Push all tags to remote repository
Definition
git push --tags origin
Term
What do Undo Local Changes do?
Definition
If you mess up, you can replace the changes in your working tree with the last content in head: git checkout --

Changes already added to the index, as well as new files, will be kept.

Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this:

git fetch origin

git reset --hard origin/master
Term
Search
Definition
Search the working directory for foo():

git grep "foo()"
Term
Define: Git Init
Definition
This command turns a directory into an empty Git repository. This is the first step in creating a repository. After running git init, adding and committing files/directories is possible.
Term
Git Init Usage:
Definition
# change directory to codebase
$ cd /file/path/to/code

# make directory a git repository
$ git init
Term
Git Init In Practice:
Definition
# change directory to codebase
$ cd /Users/computer-name/Documents/website

# make directory a git repository
$ git init
Initialized empty Git repository in /Users/computer-name/Documents/website/.git/
Term
Define: Git Add
Definition
Adds files in the to the staging area for Git. Before a file is available to commit to a repository, the file needs to be added to the Git index (staging area). There are a few different ways to use git add, by adding entire directories, specific files, or all unstaged files.
Term
Git Add Usage:
Definition
$ git add
Term
Git Add In Practice:
Definition
# To add all files not staged:
$ git add .

# To stage a specific file:
$ git add index.html

# To stage an entire directory:
$ git add css
Term
Define: Git Commit
Definition
Record the changes made to the files to a local repository. For easy reference, each commit has a unique ID.

It’s best practice to include a message with each commit explaining the changes made in a commit. Adding a commit message helps to find a particular change or understanding the changes.
Term
Git Commit Usage:
Definition
# Adding a commit with message
$ git commit -m "Commit message in quotes"
Term
Git Commit In Practice:
Definition
$ git commit -m "My first commit message"
[SecretTesting 0254c3d] My first commit message
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 homepage/index.html
Term
Define: Git Status
Definition
This command returns the current state of the repository.

git status will return the current working branch. If a file is in the staging area, but not committed, it shows with git status. Or, if there are no changes it’ll return nothing to commit, working directory clean.
Term
Git Status Usage:
Definition
$ git status
Term
Git Status In Practice:
Definition
# Message when files have not been staged (git add)
$ git status
On branch SecretTesting
Untracked files:
(use "git add ..." to include in what will be committed)

homepage/index.html

# Message when files have been not been committed (git commit)
$ git status
On branch SecretTesting
Your branch is up-to-date with 'origin/SecretTesting'.
Changes to be committed:
(use "git reset HEAD ..." to unstage)

new file: homepage/index.html

# Message when all files have been staged and committed
$ git status
On branch SecretTesting
nothing to commit, working directory clean
Term
Define: Git Config
Definition
With Git, there are many configurations and settings possible. git config is how to assign these settings. Two important settings are user user.name and user.email. These values set what email address and name commits will be from on a local computer. With git config, a --global flag is used to write the settings to all repositories on a computer. Without a --global flag settings will only apply to the current repository that you are currently in.

There are many other variables available to edit in git config. From editing color outputs to changing the behavior of git status.
Term
Git Config Usage:
Definition
$ git config
Term
Git Config In Practice:
Definition
# Running git config globally
$ git config --global user.email "my@emailaddress.com"
$ git config --global user.name "Brian Kerr"

# Running git config on the current repository settings
$ git config user.email "my@emailaddress.com"
$ git config user.name "Brian Kerr"
Term
Define: Git Branch
Definition
To determine what branch the local repository is on, add a new branch, or delete a branch.
Term
Git Branch Usage:
Definition
# Create a new branch $ git branch # List all remote or local branches $ git branch -a # Delete a branch $ git branch -d
Term
Git Branch In Practice:
Definition
# Create a new branch
$ git branch new_feature

# List branches
$ git branch -a
* SecretTesting
new_feature
remotes/origin/stable
remotes/origin/staging
remotes/origin/master -> origin/SecretTesting

# Delete a branch
$ git branch -d new_feature
Deleted branch new_feature (was 0254c3d).
Term
Define: Git Checkout
Definition
To start working in a different branch, use git checkout to switch branches.
Term
Git Checkout Usage:
Definition
# Checkout an existing branch $ git checkout # Checkout and create a new branch with that name $ git checkout -b
Term
Git Checkout In Practice:
Definition
# Switching to branch 'new_feature'
$ git checkout new_feature
Switched to branch 'new_feature'

# Creating and switching to branch 'staging'
$ git checkout -b staging
Switched to a new branch 'staging'
Term
Define: Git Merge
Definition
Integrate branches together. git merge combines the changes from one branch to another branch. For example, merge the changes made in a staging branch into the stable branch.
Term
Git Merge Usage:
Definition
# Merge changes into current branch $ git merge
Term
Git Merge In Practice:
Definition
# Merge changes into current branch
$ git merge new_feature
Updating 0254c3d..4c0f37c
Fast-forward
homepage/index.html | 297 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 297 insertions(+)
create mode 100644 homepage/index.html
Term
What does working with local repositories require? (list the different git thingies used for it)
Definition
1. Git Init
2. Git Add
3. Git Commit
4. Git Status
5. Git Config
6. Git Branch
7. Git Checkout
8. Git Merge
Term
Define: Git Remote
Definition
To connect a local repository with a remote repository. A remote repository can have a name set to avoid having to remember the URL of the repository.
Term
Git Remote Usage:
Definition
# Add remote repository
$ git remote

# List named remote repositories
$ git remote -v
Term
Git Remote In Practice:
Definition
# Adding a remote repository with the name of beanstalk
$ git remote add origin git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git

# List named remote repositories
$ git remote -v
origin git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git (fetch)
origin git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git (push)
Term
Define: Git Clone
Definition
To create a local working copy of an existing remote repository, use git clone to copy and download the repository to a computer. Cloning is the equivalent of git init when working with a remote repository. Git will create a directory locally with all files and repository history.
Term
Git Clone Usage:
Definition
$ git clone
Term
Git Clone In Practice:
Definition
$ git clone git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git
Cloning into 'repository_name'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (5/5), 3.08 KiB | 0 bytes/s, done.
Checking connectivity... done.
Term
Define: Git Pull
Definition
To get the latest version of a repository run git pull. This pulls the changes from the remote repository to the local computer.
Term
Git Pull Usage:
Definition
$ git pull
Term
Git Pull In Practice:
Definition
# Pull from named remote
$ git pull origin staging
From account_name.git.beanstalkapp.com:/account_name/repository_name
* branch staging -> FETCH_HEAD
* [new branch] staging -> origin/staging
Already up-to-date.

# Pull from URL (not frequently used)
$ git pull git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git staging
From account_name.git.beanstalkapp.com:/account_name/repository_name
* branch staging -> FETCH_HEAD
* [new branch] staging -> origin/staging
Already up-to-date.
Term
Define: Git Push
Definition
Sends local commits to the remote repository. git push requires two parameters: the remote repository and the branch that the push is for.
Term
Git Push Usage:
Definition
$ git push # Push all local branches to remote repository $ git push —all
Term
Git Push In Practice:
Definition
# Push a specific branch to a remote with named remote
$ git push origin staging
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 734 bytes | 0 bytes/s, done.
Total 5 (delta 2), reused 0 (delta 0)
To git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git
ad189cb..0254c3d SecretTesting -> SecretTesting

# Push all local branches to remote repository
$ git push --all
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 373 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To git@account_name.git.beanstalkapp.com:/acccount_name/repository_name.git
0d56917..948ac97 master -> master
ad189cb..0254c3d SecretTesting -> SecretTesting
Term
What does working with remote repositories require? (list the different git thingies used for it)
Definition
1. Git Remote
2. Git Clone
3. Git Pull
4. Git Push
Term
Define: Git Stash
Definition
To save changes made when they’re not in a state to commit them to a repository. This will store the work and give a clean working directory. For instance, when working on a new feature that’s not complete, but an urgent bug needs attention.
Term
Git Stash Usage:
Definition
# Store current work with untracked files
$ git stash -u

# Bring stashed work back to the working directory
$ git stash pop
Term
Git Stash In Practice:
Definition
# Store current work
$ git stash -u
Saved working directory and index state WIP on SecretTesting: 4c0f37c Adding new file to branch
HEAD is now at 4c0f37c Adding new file to branch

# Bring stashed work back to the working directory
$ git stash pop
On branch SecretTesting
Your branch and 'origin/SecretTesting' have diverged,
and have 1 and 1 different commit each, respectively.
(use "git pull" to merge the remote branch into yours)
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

modified: index.html

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (3561897724c1f448ae001edf3ef57415778755ec)
Term
Define: Git Log
Definition
To show the chronological commit history for a repository. This helps give context and history for a repository. git log is available immediately on a recently cloned repository to see history.
Term
Git Log Usage:
Definition
# Show entire git log
$ git log

# Show git log with date pameters
$ git log --=

# Show git log based on commit author
$ git log --="Author Name"
Term
Git Log In Practice:
Definition
# Show entire git log
$ git log
commit 4c0f37c711623d20fc60b9cbcf393d515945952f
Author: Brian Kerr
Date: Tue Oct 25 17:46:11 2016 -0500

Updating the wording of the homepage footer

commit 0254c3da3add4ebe9d7e1f2e76f015a209e1ef67
Author: Ashley Harpp
Date: Wed Oct 19 16:27:27 2016 -0500

My first commit message

# Show git log with date pameters
$ git log --before="Oct 20"
commit 0254c3da3add4ebe9d7e1f2e76f015a209e1ef67
Author: Ashley Harpp
Date: Wed Oct 19 16:27:27 2016 -0500

My first commit message

# Show git log based on commit author
$ git log --author="Brian Kerr"
commit 4c0f37c711623d20fc60b9cbcf393d515945952f
Author: Brian Kerr
Date: Tue Oct 25 17:46:11 2016 -0500

Updating the wording of the homepage footer
Term
Define: Git Rm
Definition
Remove files or directories from the working index (staging area). With git rm, there are two options to keep in mind: force and cached. Running the command with force deletes the file. The cached command removes the file from the working index. When removing an entire directory, a recursive command is necessary.
Term
Git Rm Usage:
Definition
# To remove a file from the working index (cached): $ git rm --cached # To delete a file (force): $ git rm -f # To remove an entire directory from the working index (cached): $ git rm -r --cached # To delete an entire directory (force): $ git rm -r -f
Term
Git Rm In Practice:
Definition
# To remove a file from the working index:
$ git rm --cached css/style.css
rm 'css/style.css'

# To delete a file (force):
$ git rm -f css/style.css
rm 'css/style.css'

# To remove an entire directory from the working index (cached):
$ git rm -r --cached css/
rm 'css/style.css'
rm 'css/style.min.css'

# To delete an entire directory (force):
$ git rm -r -f css/
rm 'css/style.css'
rm 'css/style.min.css'
Term
List 3 advanced Git Commands
Definition
1. Git Stash
2. Git Log
3. Git Rm
Supporting users have an ad free experience!