1. The remote branch is generated when the local branch is pushed to the server. For example, master is a typical remote branch (default).
1 |
$: git push origin master |
In addition to master, we can also create branches at will, and then push them to the server. E.g:
1 |
$: git push origin develop |
2 |
Counting objects: 27, done . |
3 |
Delta compression using up to 2 threads. |
4 |
Compressing objects: 100% (15/15), done . |
5 |
Writing objects: 100% (15/15), 7.30 KiB, done . |
6 |
Total 15 (delta 10), reused 0 (delta 0) |
8 |
1b95a57..779dbe1 develop -> develop |
2. The remote branch and the local branch need to be distinguished, so when pulling a specific branch from the server, you need to specify the local branch name.
1 |
$: git checkout --track origin/develop |
Note that this command requires git1.6.4 or above because of the --track parameter!
This way git will automatically switch to the develop branch.
3. Sync the local remote branch:
4. Submit the branch data to the remote server:
1 |
$: git push origin <local_branch_name>:<remote_branch_name> |
E.g:
1 |
$: git push origin develop:develop |
Of course, if you are currently under the develop branch, you can also directly
5. Delete the remote branch develop:
1 |
$: git push origin :develop |
There is no branch on the server when it is first created (using git init --bare). Then after the local creation, a branch needs to be pushed to the server.
That is: the first push must be written like git push origin master:master
git checkout master //Remove the head of the master version.
git checkout tag_name //Remove the version of tag_name on the current branch
git checkout master file_name //Abandon the current modification to the file file_name
git checkout branch_name tag_name //Take the version of tag_name of the specified branch branch_name
git checkout commit_id file_name //Get the version of file file_name in commit_id.
commit_id is the sha value of git commit.
List the patch corresponding to a commit ID (XXXXXXXXXXXXXXXX):
$ git log -1 -p XXXXXXXXXXXXXXXX
$ git format-patch -1 XXXXXXXXXXXXXXXX <===-1 cannot be omitted
--stdout //print to standard output
$ git show XXXXXXXXXXXXXXXX
$ git diff-tree -p XXXXXXXXXXXXXXXX