Version Control with Git (Udacity)优达学城笔记--L1:What is Version Control

来源:互联网 发布:java 在线视频播放 编辑:程序博客网 时间:2024/04/27 02:10

What is Version Control

version control: control version

Version Cotrol Systems: Git, Subversion, Mercurial

  • Centralized:all users connect to a central, master repository
  • Distributed: each user has the entire repository on their computer

git: Distributed version control system

  • git: Version control tool
  • GitHub: Service that hosts Git projects

version control system(VCS) is a tool that manages different versions of source code.

source code manager(SCM) is another name for a version control system.

Git

commit save the state of your project in Git

repository(repo) is a directory which contains your project work, as well as a few files which are used to communicate with Git.Repositories can exit either locally on your computer or as remote copy on another computer. A repository is made up of commits.

working directory is the files that you see in your computer’s file system. When you open your project files up on a code editor, you’re working with files in the Working Directory. This is in contrast to the files that have been saved(in commits!) in the repository. When working with Git, the Working Directory is also different from the command line’s concept of the current working directory which is the directory that your shell is “looking at” right now.

Checkout is when content in the repository has been copied to the Working Directory.

Staging Area/Staging Index/Index A file in the Git directory that stores information about what will go into your next commit.

SHA is basically an ID number for each commit. It is a 40-character string composed of characters(0-9 and a-f) and calculated based on the contents of a file or directory structure in Git. Secure Hash Algorithm.

Branch is when a new line of development is created that diverges from the main line of development.

Installing Git https://git-scm.com/downloads

git

usage:git [–version] [–help] [-C ] [-c name=value] [–exec-path[=]] [–html-path] [–man-path] [–info-path] [-pl–paginate|–no-pager] [–no-replace-objects] [–bare] [–git-dir=] [–work-tree=] [–namespace=] []

The most commonly used git commands are:

  • Add Add file contents to the index
  • bisect Find by binary search the change that introduced a bug
  • branch List,create,or delete branches
  • checkout Checkout a branch or paths to the working tree
  • clone Clone a repository into a new directory
  • commint Record changes to the repository
  • diff Show changes to the repository
  • fetch Download objects and refs from another repository
  • grep Print lines matching a pattern
  • init Create an empty Git repository or reinitialize an existing one
  • log Show commit logs
  • merge Join two or more development histories together
  • mv Move or rename a file, a directory, or a symlink
  • pull Fetch from and integrate with another repository or a local branch
  • push Update remote refs along with associated objects
  • rebase Forward-port local commits to the updated upstream head
  • reset Reset current HEAD to the specified state
  • rm Remove files from the working tree and from the index
  • show Show various types of objects
  • status Show the working tree status
  • tag Create, list, delete or verify a tag object signed with GPG

‘git help -a’ and ‘git help -g’ lists available subcommands and some concept guides. See ‘git help ’ or ‘git help ’ to read about a specific subcommand or concept.

Configuration Steps

cdstart .mv udacity-terminal-config .udacity-terminal-config

First Time Git Configuration

git config --global user.name "<Your-Full-Name>"        #sets up Git with your namegit config --global user.email "<your-email-address>"   #sets up Git with your emailgit config --global color.ui auto   #makes sure taht Git output is coloredgit config --global merge.conflictstyle diff3   #displays the original state in a conflictgit config --list

associate X text editor with Git

Atom Editor Setup

git config --global core.editor "atom --wait"

Sublime Text Setup

git config --global core.editor "'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl' -n -w"

VSCode Setup

git config --global core.editor "code -wait"
原创粉丝点击