-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_command
41 lines (26 loc) · 1.38 KB
/
git_command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
1. 创建一个git repository并首次上传文件的步骤:
# 首先在github主页上创建一个新的repository,比如命名为PyTorch_Notes,注意创建的时候不要添加任何的文件,比如readme。
# 然后Terminal:
cd github/PyTorch
git config --global user.name "zxw1992"
git config --global user.email "zxw1992spark@gmail.com"
git init
(git status)
git add -A # add all files in current fold
or git add <file> # add specific file
git commit -m "some commits"
git remote add origin https://github.com/zxw1992/PyTorch_Notes.git
git push -u origin master
2. 上传修改的文件或增加文件:
(git status
git diff)
git add -A # 添加所有变更的文件
(or git add file_1 file_2 ...) # 添加多个文件file_1, file_2, ...
git commit -m "commits"
(git pull origin master)
# git pull命令的作用是,取回远程主机某个分支的更新,再与本地的指定分支合并。如果远程的分支没有被修改,也就是与本地的一样,那么不需要这个步骤。但是当远程origin/master与本地的master不一致时,需要执行这个步骤。
git push origin master
# git push命令用于将本地分支的更新,推送到远程主机。上面命令表示,将本地的master分支推送到origin主机的master分支。
3. 一些命令行
git commit -h
# 显示帮助,注意如果使用git commit --help 就会显示英文文档。