git 操作实例(git commit, git push, git branch, git checkout, git reset)

来源:互联网 发布:梦幻2017改版盘丝数据 编辑:程序博客网 时间:2024/05/16 19:14

1.  modify and add files to remote server

     scp -p -P 29418 wangyonghui@10.2.48.50:hooks/commit-msg .git/hooks/

     git status 查看当前目录修改是否争取

     git branch -a 查看当前工作的branch

     git checkout -b yourbranchname             yourbranchname 是为当前工作内容起的临时branch 名字,可以是任意值

     进行修改,添加文件

     git diff 验证修改文件正确

     git status 验证添加文件正确,没有多余的文件或者临时文件

     git  add .  添加文件到本地库

     git  commit . -m "CR number , author name,  your message for this commit“

     git push aosp HEAD:refs/for/android4.4.2_r2                          aosp

     ok your code commit to remote server for review.


2. update remote server commit

     根据第一步的方式完成修改和添加文件,在git push 的时候指定更新。

     git push aosp HEAD:refs/changes/82              82 is the number you want to update


3.  remove files on remote server

    git status 查看当前目录下的文件

    git branch -a 查看当前工作的branch

    git checkout -b yourtempbranchname

    rm files

    git rm files

    git commit . -m "CR number , author name,  your message for this commit“

    git push aosp yourtempbranchname:refs/for/android4.4.2_r2

    or 

    git push aosp HEAD:refs/for/android4.4.2_r2


4. 删除临时branch name

    git branch -D yourtempbranchname


5. git reset to the version you want

     git reset --hard HEAD^ 

     彻底撤销最近的提交。引用回退到前一次,而且工作区和暂存区都会回退到上一次提交的状态。自上一次以来的提交全部丢失。

    

6.  永久删除最后提交的3个commits

     git reset --hard HEAD~3

     彻底撤销最近的3次的提交。引用回退到前三次,而且工作区和暂存区都会回退到前三次提交的状态。自前三次以来的提交全部丢失。


7.  sync your committed code only

    repo sync platform/yourcodepath

    e.g.   repo sync platform/package/fileexplorer/



0 0
原创粉丝点击