6

25个每个人都应该知道的Git命令

 3 years ago
source link: http://dockone.io/article/2434129
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

25个每个人都应该知道的Git命令


我们大多数时候都使用IDE和其他软件来编写命令,但为了更好的工作,我们还需要随时准备一些可以随手使用的命令,以备不时之需。

以下是我在开发时候,通常使用的命令,今天,我将它分享与你,希望对你有所帮助。

1、初始化本地Git存储库

git init

2、创建远程存储库的本地副本

git clone ssh://[email protected]/[username]/[repository-name].git

3、检查状态

git status

4、将文件添加到暂存区

git add [file-name.txt] 

5、将所有新文件和更改过的文件添加到登台区域

git add -A

6、提交更改

git commit -m "[commit message]"

7、删除文件(或文件夹)

git rm -r [file-name.txt]

8、列出分支(星号表示当前分支)

git branch

9、创建一个新分支

git branch [branch name] 

10、删除分支

git branch -d [branch name] 

11、创建一个新分支并切换到该分支

git checkout -b [branch name] 

12、克隆一个远程分支并切换到该分支

git checkout -b [branch name] origin/[branch name] 

13、重命名本地分支

git branch -m [old branch name] [new branch name] 

14、切换到分支

git checkout [branch name] 

15、将一个分支合并到活动分支中

git merge [branch name] 

16、将一个分支合并到一个目标分支

git merge [source branch] [target branch] 

17、将更改存储在不合适的工作目录中

git stash

18、删除所有隐藏的条目

git stash clear

19、将分支推送到你的远程存储库

git push origin [branch name] 

20、将更改推送到远程存储库

git push

21、将本地存储库更新为最新的提交

git pull

22、从远程存储库中提取更改

git pull origin [branch name] 

23、添加一个远程存储库

git remote add origin ssh://[email protected]/[username]/[repository-name].git

24、查看更改

git log

25、合并前预览更改

git diff [source branch] [target branch] 

结论

希望本指南内容对你有所帮助。还有其他我们错过的命令吗?如果是这样,请在评论中让我知道!

原文链接:https://mp.weixin.qq.com/s/rZHeVUdW6o_XjKlFKYC-pw

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK