1. 程式人生 > >git 日常 常用命令

git 日常 常用命令

文件的 gpo checkout comm rop show aop 刪除 狀態

初始化git

git init


第一次拉代碼:

方式1:git clone

https://git.oschina.net/xiaopingzi001/copyrightshow_server_java.git (https地址)

方式2:

先添加遠程倉庫remote,然後Git pull(默認分支master)

要添加一個新的遠程倉庫,可以指定一個簡單的名字,以便將來引用:
git remote add team倉庫名 https://git.oschina.net/copyrightshow/copyrightshow_activity.git(現在可以用字串team 指代對應的倉庫地址了)
git pull team master

git remote 不帶參數,列出已經存在的遠程分支
git remote -v | --verbose 列出詳細信息,在每一個名字後面列出其遠程url
git remote rename <old> <new> 重命名倉庫名稱

提交代碼:
git add .
git commit -m"first commit"
git push team(倉庫名) master(分之名)

分之:
git branch 查看本地分之
git branch -r 列出遠程分支
git branch -a 查看本地+遠程分支
git branch new_branch 創建分之(不進行切換)
git checkout -b new_branch 創建並切換分之
git checkout version2(分之名) 切換分之
git checkout .//或者git checkout a.txt 放棄本地工作區文件的修改
git checkout -b new_branch origin/branch-name
從遠程分之上創建本地分支並切換分之(遠程分之)在本地創建和遠程分支對應的分支(本地和遠程分支的名稱最好一致;)
git branch -m | -M oldbranch newbranch
重命名分支,如果newbranch名字分支已經存在,則需要使用-M強制重命名,否則,使用-m進行重命名。
git branch -d | -D branchname 刪除branchname分支
git branch -d -r branchname 刪除遠程branchname分支

git stash // 暫存當前狀態
git stash drop [<stash>] 刪除某一個進度,默認刪除最新進度
git stash apply [--index] [<stash>] 不刪除已恢復的進度,其他同git stash pop
git stash clear 刪除所有進度
git stash branch <branchname> <stash> 基於進度創建分支

git status 查看當前修改狀態(列出所有修改)

git 日常 常用命令