zoukankan      html  css  js  c++  java
  • git workflow

    1) fork map-matcher.git repo
    2) add ssh-keygen public key to gitlab
    3) clone repo
      git clone git@xxx/map-matcher.git
    4) create branch proj2dist and add new files
      git checkout -b branch-proj2dist
      git add 1.txt
      git commit -m "add 1.txt"

    5) push branch to remote branch
      git remote
      # origin
      git push origin branch-proj2dist:branch-proj2dist

    6) update branch files
      git add 2.txt
      git commit -m "add 2.txt"
      git push origin branch-proj2dist:branch-proj2dist

    #config

    git config --global user.name "Bob"
    git config --global user.email "bob@example.com"

    git config --global color.status auto
    git config --global color.branch auto

    git config --list

    #list log

    git log -5

    git log --pretty=oneline --abbrev-commit

    #list local branch

    git branch

    # list remote branch

    git branch -r

    # create new branch

    git checkout -b new-branch origin/master

    #update local branch from remote branch

    git pull origin remote-branch:local-branch

    #update remote branch from local branch

    git push origin local-branch:remote-branch

    #delete remote branch

    git checkout xxx

    git push origin :branch-test

    git push origin --delete branch-test

    #delete local branch

    #for not merged branch

    git checkout master

    git branch -D branch-test

    #for merged branch

    git branch -d branch-test 
    error: Cannot delete the branch 'branch-test' which you are currently on.

    git checkout master

    git branch -d branch-test

    #merge branch test1 into master

    git checkout master

    git merge -m "merge test1 into master" test1

    # tags

    git tag -a v0.1 -m "version 0.1"

    git tag -l

    #push tag

    git push origin refs/tags/v0.1

    git pull origin refs/tags/v0.1

    #push/fetch all tags

    git push --tags

    git fetch --tags

    #delete local tag

    git tag -d v0.1

    #delete remote tag

    git push origin :refs/tags/v0.1

    git push origin --delete refs/tags/v0.1

    git ls-remote  --heads --tags origin

    # warning: LF will be replaced by CRLF

    windows中的换行符为 CRLF, 而在Linux下的换行符为LF,所以在执行add . 时出现提示,解决办法:

    $ rm -rf .git  // 删除.git  

    $ git config --global core.autocrlf false  //禁用自动转换    

    git修改远程仓库地址 

    1.修改命令
    git remote origin set-url [url]
    2.先删后加
    git remote rm origin
    git remote add origin [url]

    git查看远程仓库

    git remote -v

    推送本地所有分支到远程

    git push --all origin

    上面命令表示,将所有本地分支都推送到origin主机。

  • 相关阅读:
    函数
    python操作文件
    POJ-2689-Prime Distance(素数区间筛法)
    POJ-2891-Strange Way to Express Integers(线性同余方程组)
    POJ-2142-The Balance
    POJ-1061-青蛙的约会(扩展欧几里得)
    Educational Codeforces Round 75 (Rated for Div. 2) D. Salary Changing
    Educational Codeforces Round 75 (Rated for Div. 2) C. Minimize The Integer
    Educational Codeforces Round 75 (Rated for Div. 2) B. Binary Palindromes
    Educational Codeforces Round 75 (Rated for Div. 2) A. Broken Keyboard
  • 原文地址:https://www.cnblogs.com/hellogiser/p/git-workflow.html
Copyright © 2011-2022 走看看