git命令总结

  VCS版本控制系统(version control system),是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统。

  git是一个开源的分布式版本控制系统,下面将列举常用的git命令。

1 #create a new repository on the command line
2 echo "# curly-memory" >> README.md
3 git init
4 git add README.md
5 git commit -m "first commit"
6 git remote add origin https://github.com/'accountname'/'reponame'.git
7 git push -u origin master
$ git config --global user.name 'Your Name'
$ git config --global user.email 'your@email' #配置git用户和email
 1 #使用当地项目创建git repo
 2 
 3 #Initialize the Git repository in the project's root directory
 4 $cd '目标文件夹'
 5 $ git init 
 6 
 7 #Stage all files in a directory to be added to the initial commit
 8 $ git add .
 9 
10 #Create an initial commit
11 $ git commit -m "Initial commit"
12 
13 $ git remote add origin <url>
14 $ git push -u origin master 
1 #Cloning an existing repository
2 $ git clone <url>
3 #update your local repository with changes from the remote repository (the one you cloned)
4 $ git pull --rebase 
1 $ git checkout <sha1> # pull a particular commit into your working copy (for example, to see how things were at the initial commit)(where <sha1> is the alphanumeric commit ID, for example, e1fec4ab2d14ee331498b6e5b2f2cca5b39daec0 for the Initial commit)
2 
3 $ git checkout -b <branch-name> # To create a new branch
4 $ git branch -a # To see a list of all branches
5 $ git checkout <branch-name> # To move to another branch
6 $ git merge <branch-name> # merge our branch into the branch we're currently on
原文地址:https://www.cnblogs.com/chester-cs/p/11261137.html