1/23
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What command is used to initiate, copy and create a shared Git repository? What is used
git init
- Only needs to be created once to create a central repository- can turn a project folder into a git repository
- git clone can be used to copy the repository to a local machine
- --bare - used when a git repository is to be shared
What is the syntax of the command for the clone command?
git clone
- repo - is the location of the repository to clone
- directory - is the location on the local machine
How do you know that a repository is a non-bare repository?
- The --bare flag creates a repository that doesn't have a working directory - making it impossible to edit files and commit changes
- you can tell that the repository is bare because the .git extension is omitted from the cloned repository - meaning no .git folder, it is an ordinary project folder
- the developer cloned versions of the bare repository are Non-bare, so development can take place in this repository
What are the scopes permissions in GIT and what are the working files that contain this information?
- local (will override user and global settings) -
- user (will override global settings) - ~/.gitconfig
- global - $(previs)/etc/gitconfig
How do you configure the current repository with user information?
- git config --global user.name
- git config --global user.email
What are some configuration details for the repository?
- git config - global alias.
- git config --system core.editor
What are the commands for adding a file and their characteristics?
- git add
- git add
- git add -p - interactive session where portions of the file can be added to the next commit
The next steps is to perform a commit
- git add hello.py
- git commit
What are the commands for a Git commit
- git commit - commits and launches the text editor to create a message
- git commit -m
- git commit -a - this commits a snapshot of all changes in the working directory. includes modifications to tracked files.
What are the differences between git and SVN
- SVN uses differences and git uses snap shots of entire files
- SVN has the central working copy in the central repository
- Git makes it easier to split up a feature into atomic commits
- Git allows cleaning up of changes before a commit takes place
- Git permits developers to work in an isolated environment
What is the difference between git status and git log?
Git status displays the state of the working directory and the staging area.
- which changes have been staged
- which files are not being tracked
Git log - displays the committed project history
How do you set a file to be ignored by Git?
there is a special file named .gitignore which lets you include files to be ignored
What are the commands provided with git log?
- git log - displays entire commit history
- git log -n
- git log --oneline - condenses each log entry to one line
- git log -p - detailed view showing the detailed view of each commit
- git log --author="
- git log --grep="
- git log
- git log
- git log --graph --decoreate -oneline -
- graph - draws a graphon the left hand side of the commit message
- decoreate - adds the names of the branches or tags of the commits
- online - shows the commit information in a single line
What is the syntax to checkout a file from Git?
git checkout master - returns the "master" branch (current state of project)
- git checkout
- git checkout
What does the "revert" command do
- used when you want to remove an entire commit from your project history
- it undoes a single commit by adding a new commit to undo the changes
- undoes a committed snapshot
- unlike 'reset' keeps track of project history
- undoes the changes introduced by the commit
- appends a new commit with the resulting content
- keeps track of these changes in history
- git revert
What does the --hard flag do for the reset command?
The --hard flag will overwrite the working directory with changes so that all traces of the previous work will be overwritten
Where is it common to use 'reset' and 'revert'
'reset' is typically used for local repositories, 'revert' is commonly used for public repositories
- 'reset' should never be used on public repositories because it can mess up others who are collaborating and when they try to sync their repositories
What is git clean used for and what are the popular flags
- git clean is used to remove untracked files from the working directory.
- not undoable - similar to the rm command
- often executed with git reset --hard
- git clean -n - show files to be removed without removing them
- git clean -f -removes from the current directory
- git clear -df removes directories as well as files
What is the purpose and syntax of a git branch
- git branch represents an independent line of development
- think of it as a brand new working directory
- new commits recorded in the history of the new branch
- will result in a fork in the history of the project
Command Syntax
- git branch - list of all branches in the repository
- git branch
- git branch -d
- git branch -m
What are the two types of merge commands and what is the difference between the two?
- Fast forward and 3-way merge
- Fast forward - the master has not changed since the branch was created so the branch is merged into the master
- 3 way merge - the master has a committed change since the branch was created. So the two must be merged. if the same file was changed in both the branch and the master, conflict resolution is required
Command Syntax
- git merge
- git merge --no-ff
How do you resolve a conflict in a 3-way merge?
- git status - shows the file(s) with a conflict
- fix the conflicting file
- git commit
What is the purpose of the git checkout and what is the syntax?
- The git checkout lets you navigate between the branches created by git branch
- similar to having the branch updated to match the selected branch/revision
Command Syntax
- git checkout
- git checkout -b -
- git checkout -b
What is being referred to by the 'HEAD' or 'detached HEAD'
HEAD - git is referring to the current snapshot
detached HEAD - when pointing to a branch. Git refers to this a detached HEAD because there would be no branch allowing you to get back to it.
Provide examples of the tasks that you can do from checking out master?
- merge in completed features from a different branch
- create a new branch
- work on the current master branch
What is the purpose of these four commands
- git remote
- git fetch
- git pull
- git push
git remote - method of managing remote connections
- git remote -v - list connections with the URLs
- add, rm, rename - add, remove, and rename a connection
git fetch - imports commits and stores them in remote branches - files can be reviewed before importing into the project
git pull - merging upstream changes into your local repository (combination of 'git fetch' and 'git merge')
git push - transfers commits from local to remote repositories