gitクライアントでの使用ノート
新しいプロジェクトではgitlabをバージョン管理ツールとして使用し、新しいサーバにgitのクライアントをインストールし、今自分が使ったコマンドをメモし、記憶を増やし、自分で後で見るのも便利です.
一、リモートのバージョンサーバーの上からコードをクローンしてローカルテストサーバーまで:
2、デフォルトブランチのコードをクローンする場合は、次のコマンドを直接使用します.
一、リモートのバージョンサーバーの上からコードをクローンしてローカルテストサーバーまで:
1、git clone -b <branch> <remote_repo> : git clone -b
[dba@localhost ~]$git clone -b preview http://username:[email protected]/project/ .git
2、デフォルトブランチのコードをクローンする場合は、次のコマンドを直接使用します.
[dba@localhost ~]$git clone http://username:[email protected]/project/ .git
3、如果本地服务器已经存在相应的分支,使用以下命令更新即可:
[dba@localhost ~]$git fetch origin master [dba@localhost ~]$git checkout
4、如果代码存在不一致,使用以下命令合并代码,使其和版本服务器保持一致[dba@localhost ~]$git merge origin/master [dba@localhost ~]$git pull
二、从本地测试服务器提交代码到版本服务器
1、git add --添加本地文件
[dba@localhost ~]$git add a.py [dba@localhost ~]$git add b.py
[dba@localhost ~]$git add c.py
2、git commit --提交更改[dba@localhost ~]$git commit -m " "
3、git push --将更改推送到服务器
[dba@localhost ~]$git push
三、版本回退问题远程代码库回退,也是需要先在本地回退之后,再将项目推送到版本服务器上面,我们的主版本是私有的,不能直接回退,我们以回退预演版本来实现回退。
1、检查本地分支是否和版本服务器一致
[dba@localhost ~]$git checkout preview
2、如果不一致,则更新本地分支[dba@localhost ~]$git pull
3、备份一下这个分支当前的情况[dba@localhost ~]$git branch preview_backup
4、查看当前版本信息[dba@localhost ~]$git log
commit a54342b1c493d30d2da7608e3c2140def8e03668 Author: luzhenshen <[email protected]> Date: Tue May 10 15:58:30 2016 +0800 b.py commit f674a93321490809b160c800cbef8946c45e7dfd Author: luzhenshen <[email protected]> Date: Tue May 10 15:58:03 2016 +0800 a.py commit 2f165dd17194b6134ac7a6098e1dc8eb4860dc27 Author: <E5><8C><97><E4><BA><AC><E6><98><93><E8><81><94><E8><BE><BE><E5><95><86><E5><8A><A1><E6><9C><8D><E5><8A><A1><E6><9C><89><E9><99><90><E5><85><AC><E5><8F><B8> <[email protected]> Date: Mon May 9 14:58:37 2016 +0800 33 commit 11cb2119cf651865a1aed7b863e607eb52e3050a Author: huangzhijie <[email protected]> Date: Mon May 9 15:54:07 2016 +0800 add open source flask
commit idを取得するには:5、ローカルをthe_にロールバックcommit_id2f165dd17194b6134ac7a6098e1dc8eb4860dc27
[dba@localhost ~]$git reset --hard 2f165dd17194b6134ac7a6098e1dc8eb4860dc27
6、删除远程分支[dba@localhost ~]$git push origin :preview