Git uses commands __github basic operations

Source: Internet
Author: User
Tags using git version control system git commands

window git download: https://git-scm.com/download/

    code management tool role  * Prevent code loss, do backup  * code version management, multiple nodes can be backed up, jumping between multiple versions  * * Multi-person development with various modes to facilitate code management what is Gitgit is an open source distributed version control system that can be used to efficiently manage size projects. Distributed and centralized: distributed: Each node is saved complete code, no explicit central server, between nodes project push download code complete code sharing centralized: code centrally managed, each time the finished code is uploaded to the central manager, and then unified download code from the central manager using Git features /span>* git can manage a wide variety of files, especially code projects, using  *nix system-distributed management , unlike centralized, which is the core difference between git and svn  * Git can support branching better and work together more easily  *  git distributed code is more secure with a globally unique commit version number  * git is an open source system  *  use git to work off the web and transfer data faster     
Git_ Introduction

git commands to install:

Linux:sudo apt-get Install git

Windows:msysgit.github.io

View version information: Git--version  

Git configuration commands:

Configuration Level      1. All users in the system can use this configuration      command: Git config           --System/etc/gitconfig   2. The current user can use this configuration      command: Git  config--global      ~/.      gitconfig3 the current project can use this configuration      command: Git config      profile: Project/.git/config
set the level of configuration

(User name and mailbox are configured before use.)

content of the configuration:
1. Configure user names
e.g. configuring the user name tedu
sudo git config--system user.name tedu
2. Configure user Mailboxes
e.g. configuring mailboxes
git config--global user.email [email protected]
3. Configuring the compiler
e.g. configuring the compiler
git config core.editor sublime
4. View configuration information
git config--list

Git basic commands

Initialize repository: Git init

( the. Git directory is automatically generated when the warehouse is initialized in a directory.) All documents working in this directory can be managed using git)

View branch status: Git status

* The default work branch is master and can be toggled by creating a new branch

File submission: Git add [file]

* Submit files to Staging area
* Submit content can be a file, multiple files separated by a space
* if * denotes all files, it can also be a directory

Delete Staging Area A file commit record: Git rm--cached Readme.txt

Sync files to the local repository: git commit-m "some message"

* Synchronization requires some additional synchronization information to be added after-m
* All changes to the workspace if you want to sync to a local repository, add---is required >commit

View Commit Log
git log
git log--pretty=oneline

Some work area commands
To view local file and Workspace differences: Git diff file

Recover files from a local repository: git checkout file

Discard workspace Modifications: git checkout--file

Movement and deletion of local warehouse files
Moving files: git mv file dir

Delete file: git rm file

* usage is the same as MV RM command. Direct commit after operation to synchronize workspace and local warehouse

Version control commands

Back to previous version: Git reset--hard head^

* The number of the head after the ^ is decided to go back to the last few versions

git reset--hard commit_id

* Use the top 7 commit, go back to the specified version

Go to the newer version
1. View all historical version numbers
Git reflog
2. Use git reset to move to the specified version

* Git Reflog will have a record of the operation, the latest operating clock on the top


Label Management

What is a tag: Add a snapshot at the current work location, save the working state, and generally use the iteration for the version.

Create a new tag: git tag v1.0

* Label at the latest commit_id by default

Add tag information: git tag v1.0-m "message"

Specify a commit_id tag: git tag v0.9 [commit_id]

View Tags
git tag #列出当前标签
Git Show v1.0 #显示标签具体信息

Delete a label
Git tag-d v1.0

Go to a label version
git reset--hard v0.9


Temporary workspace actions

Create a Save temporary workspace
Git stash

View a saved workspace
git stash List

which workspace to apply
git stash apply [email protected]{1}

Apply a previous workspace and delete
Git stash pop

Delete Workspace
git stash drop [email protected]{0} #删除某一个
Git stash Clear #删除所有

What is a branch?      branching is where everyone gets the old code, creating their own work environment, independently developed, without affecting the operations of other branches. The development is completed and then consolidated into the mainline branch.    Advantages of branching: security, does not affect other people's work, self Control Progress View current branch    git  branch        * The branch preceded by * indicates that the branch that is currently working is creating branch    git Branch  [branch_name] switch work branch    git checkout [branch] Create and switch to a new branch     -b [branch_name] branch Merge    Merge a branch into the current branch    git merge  [branch]    * merge process If there is no conflict then the current branch is a   clean state    after merging directly *  If there is a conflict, you will need to make an artificial selection and then perform the Add    commit operation     * Try to ensure that the current branch is clean before creating the    branch, to reduce the occurrence of the conflict Delete Branch -D [ Branch_name]    forcibly delete branches    that are not merged
Branching Operations
remote repository: A warehouse on a remote host. In fact, Git is distributed, and each host has a similar git structure, just called the other host's Git repository remote. Create a shared warehouse1. Create a folder mkdir Gitrepo2The Settings folder belongs to the main chown Tarena:tarena Gitrepo3. Set this folder as a shareable git repository cd gitrepo git init--Bare fly.git4. Set the local warehouse owner Chown-R Tarena:tarena fly.git add remote repository git remote add origin [email protected]127.0.0.1:/home/tarena/aid1807/gitrepo/Fly.git*ssh is used by default as a means of transmission*must be executed under a local git repository to enable local warehouse and remote warehouse associations to delete a remote host git remotely RM [Origin] pushes a local branch to a remote git push-u Origin Master* When you first push to a remote repository, add-u option, you don't need to get the project from the remote repository git clone [email protected]127.0.0.1:/home/tarena/aid1807/gitrepo/Fly.git Pull the branch or code from the remote repository to pull the remote branch and the current work branch merge Git pull Origin Dev_tom pulls the remote branch to the local, does not merge Git pulled Origin Dev_tom:de V_tom Remote Branch name local branch name code exit and pull to push local code to a connected remote repository git push git push--Force origin (when the local version is older than the remote version is overwritten with the old version of the remote edition) update the code from the remote repository git pull git fetch (if there is a new branch pulled to local does not merge with the local branch)
Remote Warehouse

GitHub

GitHub is an open source project community site. Have the most open source projects in the world. Developers can sign up for this site to build their own github repository. You can then operate the GitHub repository locally through git like a remote repository.

Git is the only code management tool specified by GitHub

Website: https://github.com/

add an SSH secret key
1. Generate SSH key pair on localhost
Ssh-keygen

* The default key pair is stored under ~/.ssh/
* The build process will prompt for a password, if the direct carriage return means no password is set

2. Enter ~/.ssh directory to replicate id_rsa.pub public key content
3. Log in to your GitHub account
Top right corner avatar drop-down menu--"Settings--"
left SSH and GPG keys--"new SSH Key--" fill in the title, add the copied content to the key text box click on the Add ...

Create a new GitHub repository
Top right + drop-down menu--"New repository--" fill in the reference name and basic description, according to the circumstances choose whether to add content such as readme, select Shared or private-click Create

Operate the GitHub Warehouse
1.git Remote GitHub Warehouse If you need to enter a password to enter your GitHub password
2. Use git push to manipulate remote repository operations

Git uses commands __github basic operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.