Git to get started

git basic articles to hand a note

【command】

$ Git init --- initialization (.git directory created in the current directory, while the current directory into a Git repository)

$ Git status --- see the current status / see what changes

$ Git add. --- add new files and need to be submitted and tracked changes

$ Git commit -m 'remarks submitted (reMark)' --- the staging area where the changes to be submitted to the local repository

$ Git pull origin master (branch name) --- pulled under the code branches to the current branch and merge

$ Git push origin master --- local master branch to push origin master

$ Git remote show origin --- view the current warehouse address

$ Git remote add origin Git address --- Add a remote repository folder for the current file

$ Git remote set-url origin Git address --- set a new warehouse address

$ Git log --- View submission history

$ Git reflog --- see the version number and submit

$ Git reset --hard head (version number) --- fallback version of the code specified

【conflict】

Generally when pulling down the code from the remote host native code (execution pull operation) will merge conflict, performance:

《《《《《《    head
==============
=|=|=|=|=|=|=|=|=

  solve:

  1. After git pull origin master execution,
  2. View the status of git status, red for the conflict files,
  3. After modifying the file, re-git add commit push

 For pulling combined understood:

git pull = fetch (pull) + merge (merging); Bottom:

  git fetch origin master --- // pull the latest content from the master branch of the remote host
     git merge FETCH_HEAD --- // will pull down the latest content into the branch you're in
A branch of the forthcoming update to retrieve the remote host, and specify the local branch of the merger, the full format can be expressed as:
  $ Git pull <remote host name> <remote branch name>: <local branch name>
If the remote branches are combined with the current branch, the portion of the colon can be omitted:
  $ git pull origin next

Gangster draw comments:

Remember, the pull is acquired and merged.

  • git pull origin master branch acquired from origin to submit remotely master (enter local origin / master branch), then the origin / master merge into your currently checked out branch.

  • git pull only when you check out of the branch is tracking upstream branch when working. For example, if you check out the original branch trace / Master,git pullit is equivalent togit pull origin master

Guess you like

Origin www.cnblogs.com/acongya/p/11899459.html
Recommended