git使用方法的详细教程

来源:互联网 发布:程序员猝死率多少 编辑:程序博客网 时间:2024/05/17 19:18
cd进入到你需要提交到的目标目录下
然后将本地文件cp到当前目录cp /home/zhou/Code/qingstor-sdk-java/docs/template/ ./ -r(-r表示递归)
将本地文件add到目标目录git add 本地文件
提交 git commit -m "commit目的"
最后使用git push提交



创建新分支:git branch name

切换到当前新建分支下:gti checkout name

提交:git push --set-upstream origin name


push错误信息

To git@github.com:Eritic/qingstor-sdk-java.git
 ! [rejected]        update-docs -> update-docs (non-fast-forward)
error: failed to push some refs to 'git@github.com:Eritic/qingstor-sdk-java.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

使用git push -f进行强制push



git commit --amend  修改branch最开始的commit

git log   打印commit的log message

git rebase -i HEAD~N   commit merge

场景如下:假如我们使用"git add filename,git commit -m " message" ",但是在你push之前需要修改这个file,那么我们此时只需要使用"git commit -amend"然后再退出就好了,这样就会将我们修改的file保存下来,最后push一一下就好