git的入门

来源:互联网 发布:妮维雅唇膏 知乎 编辑:程序博客网 时间:2024/05/18 02:45
linux 安装git指令
sudo apt-get install git

git clone [网址]


假设本地的代码位 test.py
git提交代码到github:git add test             (暂存区)
查询状态:           git status
提交:               git commit -m '1 commit'


更新本地代码 : git pull

查询日志:      git log

强制重置代码版本:  git reset --hard  (版本号序列号前几位即可)
                  或者  git reflog  查询每次的版本号 
                        git reset --hard  (版本号序列号前几位即可)

代码撤销:
工作区: git checkout -- filename
暂存区: git reset HEAD filename    
本地代码库(已到commit到分支)git reset --hard 版本号
远程代码库: 等着跪把。。。。。


创建分支: git branch [branchname]
切换分支: git checkout [branchname]
创建并切换分支: git checkout -b [branchname]

分支的push 和pull:
如果是push或者pull master: 直接写git push/pull master
如果是push或者pull其他分支,则写成git push/pull origin [分支名字]

分支的合并:

git merch [分支的名字]


0 0