SOMS/git常用命令.md
2024-08-21 16:50:14 +08:00

78 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Git 常用命令速查
+ git branch 查看本地所有分支
+ git status 查看当前状态
+ git commit 提交
+ git branch -a 查看所有的分支
+ git branch -r 查看远程所有分支
+ git commit -am "init" 提交并且加注释
+ git remote add origin git@192.168.1.119:ndshow
+ git push origin master 将文件给推到服务器上
+ git remote show origin 显示远程库origin里的资源
+ git push origin master:develop
+ git push origin master:hb-dev 将本地库与服务器上的库进行关联
+ git checkout --track origin/dev 切换到远程dev分支
+ git branch -D master develop 删除本地库develop
+ git checkout -b dev 建立一个新的本地分支dev
+ git merge origin/dev 将分支dev与当前分支进行合并
+ git checkout dev 切换到本地dev分支
+ git remote show 查看远程库
+ git add .
+ git rm 文件名(包括路径) 从git中删除指定文件
+ git clone git://+ github.com/schacon/grit.+ git 从服务器上将代码给拉下来
+ git config --list 看所有用户
+ git ls-files 看已经被提交的
+ git rm [file name] 删除一个文件
+ git commit -a 提交当前repos的所有的改变
+ git add [file name] 添加一个文件到+ git index
+ git commit -v 当你用v参数的时候可以看commit的差异
+ git commit -m "This is the message describing the commit" 添加commit信息
+ git commit -a -a是代表add把所有的change加到+ git index里然后再commit
+ git commit -a -v 一般提交命令
+ git log 看你commit的日志
+ git diff 查看尚未暂存的更新
+ git rm a.a 移除文件(从暂存区和工作区中删除)
+ git rm --cached a.a 移除文件(只从暂存区中删除)
+ git commit -m "remove" 移除文件(从+ Git中删除)
+ git rm -f a.a 强行移除修改后文件(从暂存区和工作区中删除)
+ git diff --cached 或 $ + git diff --staged 查看尚未提交的更新
+ git stash push 将文件给push到一个临时空间中
+ git stash pop 将文件从临时空间pop下来
---------------------------------------------------------
+ git remote add origin + git@+ github.com:username/Hello-World.+ git
+ git push origin master 将本地项目给提交到服务器中
-----------------------------------------------------------
+ git pull 本地与服务器端同步
-----------------------------------------------------------------
+ git push (远程仓库名) (分支名) 将本地分支推送到服务器上去。
+ git push origin serverfix:awesomebranch
------------------------------------------------------------------
+ git fetch 相当于是从远程获取最新版本到本地不会自动merge
+ git commit -a -m "log_message" (-a是提交所有改动-m是加入log信息) 本地修改同步至服务器端
+ git branch branch_0.1 master 从主分支master创建branch_0.1分支
+ git branch -m branch_0.1 branch_1.0 将branch_0.1重命名为branch_1.0
+ git checkout branch_1.0/master 切换到branch_1.0/master分支
du -hs
+ git branch 删除远程branch
+ git push origin :branch_remote_name
+ git branch -r -d branch_remote_name
-----------------------------------------------------------
初始化版本库,并提交到远程服务器端
mkdir WebApp
cd WebApp
+ git init 本地初始化
+ git commit -m 'first commit'
+ git remote add origin + git@+ github.com:daixu/WebApp.+ git
增加一个远程服务器端
上面的命令会增加URL地址为'git@+ github.com:daixu/WebApp.git'名称为origin的远程服务器库以后提交代码的时候只需要使用 origin别名即可
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin http://192.168.110.57:3000/guor/XXXX.git
git push -u origin master