Recent projects require GIT for version management, and business hours to sort out common git commands.
1. Build a git repository on the server side
[Email protected] ~]$ pwd
/home/vagrant
[Email protected] ~]$ mkdir-p ~/git/gittest.git
[Email protected] ~]$ CD git/gittest.git/
[email protected] gittest.git]$ git init--bare
Initialized Empty Git repository in/home/vagrant/git/gittest.git/
2. Copy the new Git repository on the development machine
Angel:gittest $ git clone [email protected]:~/git/gittest.git
Cloning into ' gittest ' ...
Warning:you appear to has cloned an empty repository.
Checking connectivity ... done.
Angel:gittest $ ll
Total 0
Drwxr-xr-x 3 Angel Staff 102 5 4 16:09 Gittest
3. List, add, delete the remote repository alias
Angel:gittest $ git remote add github [email protected]:xxxxx/test.git #添加远端仓库
Angel:gittest $ git remote-v #罗列远端仓库
GitHub [email protected]Github.com:XXXXX/test.git (Fetch)
GitHub [email protected]Github.com:XXXXX/test.git (push)
Origin [email protected]:~/git/gittest.git (FETCH)
Origin [email protected]:~/git/gittest.git (push)
Angel:gittest $ git remote rm GitHub #删除远端仓库
Angel:gittest $ git remote-v
Origin [email protected]:~/git/gittest.git (FETCH)
Origin [email protected]:~/git/gittest.git (push)
4, push data to the remote warehouse
git push [alias] [branch]: Push a local [branch] branch to [branch] branch on the far end of [alias]
Angel:gittest $ git push Origin master:master
Counting Objects:3, done.
Writing objects:100% (3/3), 239 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (Delta 0)
to [email protected]:~/git/gittest.git
* [New branch] Master, master
Git push Origin master:master, there are 2 master, as a novice, often do not understand the difference between the 2 master.
The first master is the local branch, the second master is the remote branch, and the following push methods will be clearer.
Angel:gittest $ git push Origin master:test
Total 0 (Delta 0), reused 0 (Delta 0)
to [email protected]:~/git/gittest.git
* [New branch] master, test
As indicated above, the local master branch content is pushed to the test branch of the remote origin.
5. Pull data to Local
Angel:gittest $ git fetch Origin
Remote:counting Objects:3, done.
Remote:total 3 (Delta 0), reused 0 (Delta 0)
Unpacking objects:100% (3/3), done.
From 192.168.33.10:~/git/gittest
* [New branch] master, Origin/master
* [New branch] test--origin/test
It is important to note that after the fetch operation has downloaded the new remote branch, you still cannot edit the branch in the remote repository locally. In other words, in this case, you don't have a new test branch, just a origin/test pointer that you can't move.
If you want to develop a test of your own, you can differentiate a new branch on the basis of a remote branch:
Angel:gittest $ git checkou-b test origin/test
git: ' Checkou ' is not a git command. See ' Git--help '.
Angel:gittest $ git checkout-b test origin/test
Branch Test set up to track the remote Branch test from Origin.
Switched to a new branch ' test '
6. Export
Angel:gittest $ git tag
ad7b
V1
Assuming that tag v1 is exported, it can be exported as follows.
1). Export and compress to ZIP format:
Angel:gittest $ git archive--format=zip--output=v1.0.zip v1
2). Export and compress to TAR.BZ2 format:
Angel:gittest $ git Archive v1 | bzip2 > v1.0.tar.bz2
3). Export and compress to tar.gz format:
Angel:gittest $ git Archive v1 | bzip2 > v1.0.tar.bz2
Generate the following files separately
Angel:gittest $ ll
Total 40
-rw-r--r--1 Angel Staff 231 5 4 22:34 v1.0.tar.bz2
-rw-r--r--1 Angel Staff 224 5 4 22:34 v1.0.tar.gz
-rw-r--r--1 Angel Staff 187 5 4 22:33 V1.0.zip
Write it down here first.
git use notes