git 基础(Git Foundation)

一.管理分支

1.查看分支

git branch

2.查看远程分支

git branch -r

3.查看所有分支

git branch -a

4.本地创建新的分支

git branch [branch name]

5.切换到新的分支

git checkout [branch name]

6.创建+切换分支

git checkout -b [branch name]

7.将新分支推送到远程仓库

git push origin [branch name]

8.删除本地分支

git branch -D [branch name]

9.删除github远程分支

分支名前的冒号代表删除

git push origin :[branch name]

10.拉取远程分支并创建本地分支

git checkout -b 本地分支名 origin/远程分支名

二.本地提交代码

1.切换到新的分支

git checkout [branch name]

2.添加本地需要提交代码

git add .

3.提交本地代码

git commit -m "add my code to new branch"

4.push 到git仓库

git push origin [branch name]

5.拉取代码

git pull --rebase origin [branch name]
————————

1、 Management Branch

1. View branches

git branch

2. View remote branches

git branch -r

3. View all branches

git branch -a

4. Create a new branch locally

git branch [branch name]

5. Switch to the new branch

git checkout [branch name]

6. Create + switch branch

git checkout -b [branch name]

7. Push the new branch to the remote warehouse

git push origin [branch name]

8. Delete local branch

git branch -D [branch name]

9. Delete GitHub remote branch

The colon before the branch name represents deletion

git push origin :[branch name]

10. Pull the remote branch and create the local branch

git checkout -b 本地分支名 origin/远程分支名

2、 Local submission code

1. Switch to the new branch

git checkout [branch name]

2. Add local code to be submitted

git add .

3. Submit local code

git commit -m "add my code to new branch"

4. Push to git warehouse

git push origin [branch name]

5. Pull code

git pull --rebase origin [branch name]