安装git

安装git
yum install git


创建repository
mkdir learngit
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# pwd
/root/learngit


初始化git
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# git init
Initialized empty Git repository in /root/learngit/.git/
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# ls -al
total 12
drwxr-xr-x  3 root root 4096 Feb  2 10:52 .
dr-xr-x---. 7 root root 4096 Feb  2 10:45 ..
drwxr-xr-x  7 root root 4096 Feb  2 10:52 .git


note:默认生成一个.git的隐藏文件


添加一个文件
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# mkdir server
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# ls
server  server.py
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# mv server.py  server/
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# ls
server
[root@iZuf62qvg0f9vpzsiinl2vZ learngit]# cd server/
[root@iZuf62qvg0f9vpzsiinl2vZ server]# ls
server.py
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git add server.py 


[root@iZuf62qvg0f9vpzsiinl2vZ server]# git commit -m "commit a python file"


*** Please tell me who you are.


Run


  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"


to set your account's default identity.
Omit --global to set the identity only in this repository.
需要先创建一个用户和配置email
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git config --global user.name weeknd
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git config --global user.email "weeknd.su@hotmail.com"


[root@iZuf62qvg0f9vpzsiinl2vZ server]# git commit -m "commit a python file"
[master (root-commit) 3c2979c] commit a python file
 1 file changed, 35 insertions(+)
 create mode 100644 server/server.py




修改文件
server = socketserver.ThreadingTCPServer(('47.100.168.95', 999, ), MyServer)


查看文件状态
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   server.py
#
no changes added to commit (use "git add" and/or "git commit -a")


显示server.py被修改了




查看修改的内容
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git diff
diff --git a/server/server.py b/server/server.py
index a75b60e..c181ed9 100644
--- a/server/server.py
+++ b/server/server.py
@@ -30,6 +30,6 @@ class MyServer(socketserver.BaseRequestHandler):
             conn.sendall(bytes(inp, encoding="utf-8"))
 
 if __name__ == "__main__":
-    server = socketserver.ThreadingTCPServer(('127.0.0.1', 999, ), MyServer)
+    server = socketserver.ThreadingTCPServer(('47.100.168.95', 999, ), MyServer)
     server.serve_forever()






提交修改
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git add server.py


再次查看状态
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   server.py
#


提交文件
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git commit -m "update ip:47.100.168.95"
[master 583bbc2] update ip:47.100.168.95
 1 file changed, 1 insertion(+), 1 deletion(-)




再次查看状态
[root@iZuf62qvg0f9vpzsiinl2vZ server]# git status
# On branch master
nothing to commit, working directory clean
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值