Git- view remote branches, local branches, create a branch
1. Check local branch
$ git branch * br-2.1.2.2 master
2. Check remote branch
$ git branch -r origin/HEAD -> origin/master origin/feature/IOS_visualtrack origin/feature/android_visualtrack origin/master
3. Review all branches
$ git branch -a * br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/br-2.1.2.1 remotes/origin/br-2.1.2.2 remotes/origin/br-2.1.3 remotes/origin/master
4. Remote switching branch
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/Release
remotes/origin/master
$ git checkout -b myRelease origin/Release
Branch myRelease set up to track remote branch Release from origin.
Switched to a new branch 'myRelease'
PS: role checkout remote branch Release, named myRelease local branch, and switch to the local branch myRelase
5. merging branches
Before the merger first cut back to be incorporated into the branch
The following issue1234 branch said we should merge into the master branch
$: git checkout master $: git merge issue1234 Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
6. commit a content of (this operation will be completely rolled back to an edition, it will also become a local source on a version of the content) Undo
git reset --hard <commit-id>
The following pledged to undo the "update build gradle configuration file" This time the commit id, return to "add battery settings ui" This time the commit id,
xp.chen@YC-JG-YXKF-PC27 MINGW64 /f/ob ((c8303a9...)) $ git log commit c8303a9e8db2bcf4edb7488e722a380f4e8858ec (HEAD) Author: xp.chen <[email protected]> Date: Sat Oct 28 09:28:51 2017 +0800 update build gradle configuration file Change-Id: I9ee532fd0d4698613698a64eb754fb98a8559e32 commit 8d8e5ccf24cf6836ab780aa3860270c3876e825a Author: xp.chen <[email protected]> Date: Sat Oct 28 09:02:01 2017 +0800 add battery settigns ui Change-Id: Ia907ee4e84f54c00a186d31378a7925a6adaba0e xp.chen@YC-JG-YXKF-PC27 MINGW64 /f/ob ((c8303a9...)) $ git reset --hard 8d8e5ccf24cf6836ab780aa3860270c3876e825a HEAD is now at 8d8e5cc add battery settigns ui xp.chen@YC-JG-YXKF-PC27 MINGW64 /f/ob ((8d8e5cc...)) $ git log commit 8d8e5ccf24cf6836ab780aa3860270c3876e825a (HEAD) Author: xp.chen <[email protected]> Date: Sat Oct 28 09:02:01 2017 +0800 add battery settigns ui Change-Id: Ia907ee4e84f54c00a186d31378a7925a6adaba0e
7. git commit -m comment wrap
git commit -m annotations may wrap by single quotes, for example:
$ git commit -m ' > 1.aaaaa > 2.bbbb > ' [master b25154b] 1.aaaaa 2.bbbb 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ss.txt
You can view the log information is just by git commit --amend command
1.aaaaa 2.bbbb
github to build a remote branch, see local issues
The reason: Git branch -a view that the local repository of all the branches of the new remote is no preamble can not see
Resolved: $ git checkout master // first cut into the master branch
$ Git pull // synchronization at master or git fetch --all
$ Git branch -a // check to see all the local library branch
Then you will find the local branch of a remote repository to date with all branches of the
git remote branch has been removed, you can still see local
- Use git branch -a command to see all the local branch and a remote branch, we found that many in remote warehouse has been deleted branches can still be seen locally.
-
Use the command git remote show origin, you can view the remote address, remote branches, as well as the local branch Correspondingly information relations.
-
At this point we can see what a remote repository branch does not exist, follow the prompts, using git remote prune origin command:
This will delete the local success in remote branch that does not exist.
1. Check local branch
$ git branch * br-2.1.2.2 master
2. Check remote branch
$ git branch -r origin/HEAD -> origin/master origin/feature/IOS_visualtrack origin/feature/android_visualtrack origin/master
3. Review all branches
$ git branch -a * br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/br-2.1.2.1 remotes/origin/br-2.1.2.2 remotes/origin/br-2.1.3 remotes/origin/master
4. Remote switching branch
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/Release
remotes/origin/master
$ git checkout -b myRelease origin/Release
Branch myRelease set up to track remote branch Release from origin.
Switched to a new branch 'myRelease'
PS: role checkout remote branch Release, named myRelease local branch, and switch to the local branch myRelase
5. merging branches
Before the merger first cut back to be incorporated into the branch
The following issue1234 branch said we should merge into the master branch
$: git checkout master $: git merge issue1234 Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
6. commit a content of (this operation will be completely rolled back to an edition, it will also become a local source on a version of the content) Undo
git reset --hard <commit-id>
The following pledged to undo the "update build gradle configuration file" This time the commit id, return to "add battery settings ui" This time the commit id,
xp.chen@YC-JG-YXKF-PC27 MINGW64 /f/ob ((c8303a9...)) $ git log commit c8303a9e8db2bcf4edb7488e722a380f4e8858ec (HEAD) Author: xp.chen <[email protected]> Date: Sat Oct 28 09:28:51 2017 +0800 update build gradle configuration file Change-Id: I9ee532fd0d4698613698a64eb754fb98a8559e32 commit 8d8e5ccf24cf6836ab780aa3860270c3876e825a Author: xp.chen <[email protected]> Date: Sat Oct 28 09:02:01 2017 +0800 add battery settigns ui Change-Id: Ia907ee4e84f54c00a186d31378a7925a6adaba0e xp.chen@YC-JG-YXKF-PC27 MINGW64 /f/ob ((c8303a9...)) $ git reset --hard 8d8e5ccf24cf6836ab780aa3860270c3876e825a HEAD is now at 8d8e5cc add battery settigns ui xp.chen@YC-JG-YXKF-PC27 MINGW64 /f/ob ((8d8e5cc...)) $ git log commit 8d8e5ccf24cf6836ab780aa3860270c3876e825a (HEAD) Author: xp.chen <[email protected]> Date: Sat Oct 28 09:02:01 2017 +0800 add battery settigns ui Change-Id: Ia907ee4e84f54c00a186d31378a7925a6adaba0e
7. git commit -m comment wrap
git commit -m annotations may wrap by single quotes, for example:
$ git commit -m ' > 1.aaaaa > 2.bbbb > ' [master b25154b] 1.aaaaa 2.bbbb 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ss.txt
You can view the log information is just by git commit --amend command
1.aaaaa 2.bbbb
The reason: Git branch -a view that the local repository of all the branches of the new remote is no preamble can not see
Resolved: $ git checkout master // first cut into the master branch
$ Git pull // synchronization at master or git fetch --all
$ Git branch -a // check to see all the local library branch
Then you will find the local branch of a remote repository to date with all branches of the