zoukankan      html  css  js  c++  java
  • git常用命令

    git config --global user.name yourname
    git config --global user.email youremail
    # configure your info to be record when you commit your code, you can see all config info by
    git config --list

    git init / git init dirname
    #initial a new repo at current dir or specified dir , and will generate a dir named .git and create a master branch

    git clone <remote repo address> <local dirpath>
    #clone remote repo to current dirpath or specified dirpath in command line

    git status
    # check status for your project, tracked or untracked files presents? files added to commit?

    git add <file1> <file2> <dir1> <.>
    #add specified files or dirs into stage to be committed

    git reset HEAD <file>
    # when you run git add <file>, then you want to undo, then run git reset HEAD <file> to unstage

    git diff <file>
    # only show changed in workspace for file

    git diff --cached
    # only show changed in stage

    git diff HEAD
    # show changes both in workspace and stage

    git commit -m your_message
    # commit files in stage to .git

    git commit -am your_message
    # skill git add , commit directly to .git from workspace

    git rm <file>
    # remove file from workspace if you haven't added it to stage, then using git add or git commit -a

    git rm -f <file>
    # similar with git rm <file> except the file have added into stage already

    git rm --cached <file>
    # only remove from stage, it will stay in workspace

    git branch
    # list all your local branch

    git branch branchname
    # create a new local branch

    git checkout branchname
    # switch branch

    git checkout -b branchname
    # create then switch to new branch

    git branch -d branchname
    # delete a branchname

    git merge branchname
    # merge branchname to your current branch

    git log
    # view all history commit record

    git log --oneline
    # view only oneline for each commit

    git log --graph
    # view history branch changes

    git log --author=eric --oneline 5
    # view first 5 commit by eric, and show oneline for each commit

    git log --oneline --before={3.weeks.ago} --after={2010-04-18} --no-merges
    # view logs in specified time , no-merges means to hide merge commit


    git tag
    # list all tags

    git tag -a v1.0
    # tag v1.0 to newest commit

    git tag -a v1.1 commitid
    # tag to a specified commit id, you can get id by using git log


    git remote <-v>
    # list remote repo you config

    git remote add repo_name url
    # create a new remote repo that links to your local repo (url is github or gitlab)

    git push -u origin master
    # push local to your remote repo named origin at master branch


    git fetch origin
    # update new data from remote origin repo to local branch

    git merge origin/master
    # after git fetch, merge with local master

    git push origin master
    # push data to remote origin master

    git remote rm name
    # remove remote repo

  • 相关阅读:
    常见事务码说明
    常见表说明
    确认工序
    锐捷万兆交换机开启远程登录
    华为交换机相关命令
    ip网络
    深入css过渡transition
    KVM虚拟机两种配置的概念不同之处
    SSH连接服务器时,长时间不操作就会断开的解决方案
    HTTP状态码
  • 原文地址:https://www.cnblogs.com/happyuu-2019/p/11447120.html
Copyright © 2011-2022 走看看