gitlab 基本指令

A little lookup for commands I use frequently

  1. Commit all edited files and add a message

    git commit -a -m “My commit”

  2. Add all new files

    git add .

  3. Perform a pull operation

    git pull REMOTENAME BRANCHNAME

  4. Perform a push operation

    git push REMOTENAME BRANCHNAME

  5. Prune all stale remote tracking branches

    git remote prune REMOTENAME

  6. Create a branch

    git branch BRANCHNAME

  7. View branches

    git branch

  8. Checkout a different branch

    git checkout BRANCHNAME

  9. Checkout a remote branch

    git checkout -b LOCALBRANCHNAME origin/REMOTEBRANCHNAME

  10. Merge the changes made in another branch in to the current branch

    git merge BRANCHNAME

  11. Delete a local branch

    git branch -d BRANCHNAME

  12. Delete a remote branch

    git push origin :BRANCHNAME

  13. Delete a remote branch (sexier syntax)

    git push origin –delete BRANCHNAME

  14. Scrap uncommitted state and return the working tree to the last committed state

    git reset –hard HEAD

  15. Delete the latest commit, and return to the one previous (one before HEAD)

    git reset –hard HEAD~1

  16. Return a single file to it’s last committed state

    git checkout – FILENAME
    git checkout HEAD FILENAME
    Git log
    git log
    git log –pretty=oneline
    git log –pretty=short

  17. Cherry pick commits and apply them to another branch (first grab the commit ID from the branch with said commit, then checkout the branch you wish to apply the commit to)

    git cherry-pick COMMIT-ID

  18. Stash uncommitted changes

    git stash save “message”

  19. Apply stashed changes somewhere

    git stash apply

  20. Stop a file being tracked (but do not delete it from the working directory, add to .gitignore etc after this)

    git rm –cached

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值