git init
//拉去远程仓库的代码
git remote add origin gitxxx.git
git pull origin master
git push -u origin master
// 提交到远程仓库
touch 1.txt
git add 1.txt
git commit -m'添加了一个文件'
git push -u origin master
有一些注意点:
1. git commit -am 的用法
新增了一个 1.txt文件 不能直接用 git commit -am
git commit -m 用于 提交暂存区域的文件,git commit -am 用于提交被跟踪管理
的文件
我新增了 1.txt,这个文件属于untracked(未跟踪),这样的文件不能提交,使用 git add 1.txt ,将文件标记为已跟踪(或者 git add .)
已经给 git add 过的文件已经被跟踪了,那么就 可以直接 使用 git commit -am 提交了
2.解决分支冲突的 方法
git checkout --our 1.txt
或者
git checkout --theirs 1.txt
然后
git add 1.txt
再 git commit -m’手动选择了 我的或者他修改了的代码提交’