Common git commands

Source: Internet
Author: User
Tags git commands

# 下载一个项目和它的整个代码历史$ git clone [url]

# add specified file to staging area  $ git Add    [file1   ]    [file2   ]   .   .   .           

# 添加当前目录的所有文件到暂存区$ git add .

# 提交暂存区到仓库区$ git commit -m [message]
< Span class= "token punctuation" ># commit staging area specified file to warehouse area  $ git commit    [file1   ]    [file2   ]   .   .   .   -M    [Message   ]                  


# 列出所有本地分支$ git branch

 

# 列出所有本地分支和远程分支$ git branch -a


< Span class= "token operator" > # a new branch, but still stays in the current branch  $ git branch    [branch   -name   ]            


# 新建一个分支,并切换到该分支$ git checkout -b [branch]
# Switch to the specified branch and update the workspace $ git checkout   [branch-name]   


< Span class= "token operator" >  < Span class= "token operator" ># switch to previous branch  $ git Checkout   -         


# Delete Branch $ git Branch -  D   [branch-name]  


# 显示有变更的文件$ git status
# 显示当前分支的版本历史$ git log


# show code differences for staging area and Workspaces $ git diff 


# Show metadata and content changes for a commit $ git show   [Commit]  


# 从本地master拉取代码更新当前分支:branch 一般为master
$ git rebase [branch]



#更新远程仓储
$ git remote update

< Span class= "token punctuation" > < Span class= "token punctuation" ># retrieve changes to the remote repository and merge  $ git pull  with the local branch   [remote   ]  Span class= "token punctuation" >  [branch   ]      


< Span class= "token comment" >  # upload locally designated branch to remote warehouse  $ git push    [ Remote   ]    [ Branch   ] 

< Span class= "token punctuation" > # reset staging area and workspace, consistent with last commit  $ git reset   --hard          
< Span class= "token punctuation" > < Span class= "token punctuation" >               
 

Common git commands

Related Article

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: [email protected] 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.