1、先配置本地Git
E:\personal>git config –-global user.name "lewy"
E:\personal>git config –-global user.email "[email protected]"
查看是否添加成功
E:\personal>git config --global -l
user.name=lewy
2、选定你的工作目录,在目录下执行
E:\personal\gitdemo>git init
Initialized empty Git repository in E:/personal/gitdemo/.git/
此时就会在该目录下会生成一个隐藏的文件夹
E:\personal\gitdemo>ls -a
. .. .git
3、拉取远程服务器的文件到本地目录
E:\personal\gitdemo>git clone https://[email protected]/u/bbe/
Cloning into 'nbe'...
remote: Counting objects: 6, done.
Unpacking objects: 100% (6/6), done.
Checking connectivity... done.
E:\personal\gitdemo>ls -a
. .. .git bbe
4、修改文件后提交(假设修改的是de.doc)
E:\personal\gitdemo\nbe>ls -a
. .. .git de.doc
4.1 添加
E:\personal\gitdemo\nbe>git add de.doc
4.2 提交
E:\personal\gitdemo\nbe>git commit -m "modify memo"
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
4.3 上传,输入用户名和密码
E:\personal\gitdemo\nbe>git push origin master
Password for 'https://[email protected]': 在这里输入密码
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 1.35 KiB | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Scanning pack: 100% (3/3), done.
remote: Storing objects: 100% (3/3), done.
remote: Processing commits: 100% (1/1), done.
To https://[email protected]/p/bbe/
082359a..ad267c1 master -> master
4.4 整个过程中可以使用下面的命令查看当前处理状态。
E:\personal\gitdemo\nbe>git status
5、新增文件后提交(假设修改的是test1.cpp)和修改类似
E:\personal\gitdemo\nbe>ls -a
. .. .git de.doc test1.cpp
E:\personal\gitdemo\nbe>git add test1.cpp
E:\personal\gitdemo\nbe>git commit -m "add memo"
E:\personal\gitdemo\nbe>git push origin master