安装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
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