Use git notes

 

GIT use notes

 

1. Create a server git repository git init --bare

Creating a repository directory as a server, such as server

cd server
git init --bare
cd ..
sudo chmod -R a+w server

 

2. Cloning a remote server in the local repository git clone

Local warehouse assume named local

sudo git clone [email protected]:/Users/zjq/githome/server local

After execution, the following message appears:

warning: You appear to have cloned an empty repository.
Checking connectivity... done

cd local
ls -al 

We can see .git directory, indicating the local warehouses have been cloned generation.

 

3. Submit git add files to the staging area

Create a new file, for example f01.c

sudo vim f01.c

Then execute

git status

You will see the following prompt

# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    f01.c
nothing added to commit but untracked files present (use "git add" to track)

Excuting an order

sudo git add f01.c
git status

You will see the prompt has changed, as follows:

# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#    new file:   f01.c

 

 4. The staging area is already in the file submitted to the local repository. git commit

F01.c front of the file has been submitted to the staging area, and then execute the following command:

sudo git commit f01.c -m "f01.c"

After the execution, a message appears:

[master (root-commit) 843f55f] f01.c
 1 file changed, 1 insertion(+)
 create mode 100644 f01.c

And then execute the command

git status

Tip information:

# On branch master
nothing to commit, working directory clean

 

 5. Submit to the remote server repository git push

The warehouse will continue to submit local repository files to the server side, origin represents the remote server, master represents the local current branch warehouse, execute the command:

sudo git push origin master

After the execution message:

Counting objects: 3, done.
Writing objects: 100% (3/3), 204 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/Users/zjq/githome/server
 * [new branch]      master -> master

 

6. Review the local branch warehouses and remote repository git branch

Check local branch warehouse, execute the command:

git branch

Display message:

* master

master branch name, branch in front of the * denotes current work.

View remote server-side warehouse, execute the command:

git branch -r

Display message:

 origin/master

 

7. Create a new branch git branch new branch name

In the current branch node, create a new branch, the command:

sudo git branch branch001

That created a branch called branch001, you can view with the git branch command.

In each create a new branch of the time, the most current version of the branch's work at that time which will serve as the starting point of a new branch built version, that version of the new branch of the old from the latest version of the branches start.

 

8. The handover branch git checkout

Handover branch, the command:

sudo git checkout branch001

The current work is about to switch to a branch branch01.

 

9. merging branches git merge

Merge branch to the main branch branch001 master, a command to switch to the checkout using the first master, and then merge merge command:

sudo git checkout master
sudo git merge branch001

If there is a conflict, you will be prompted to call git status to view the file conflict.

Conflict resolution, and then call git add the file to solve scratch.
After all conflict resolution, git commit to commit the changes.

 

 

10. Remove the branch git branch -d name to be deleted branches orgit branch -D branch name to be deleted

Execute git branch -d <branch name>

If the branch is not merged into the master branch will complain, you can use the following command to force delete git branch -D <branch name>

sudo git branch -d branch001
sudo git branch -D branch002

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Intelligent Recommendation

svn and git use notes

This happened last week several things: Google released SHA-1 collision secure encryption examples Cloudflare leaked encrypted data networking session linux kernel vulnerability CVE-2017-6074 Encrypti...

Notes Use git (II)

Undo operation In the course of recent use git, sometimes I encountered such a problem: habitual "add -A", which will be all the modifications are added to the staging area, but had to modif...

Use a git notes:

Get code into Bitbucket fast using the command line Set up your local directory Set up Git on your machine if you haven't already. Create your first file, commit, and push...

GIT use and error Notes

As a very useful free version management tools, GIT has many advantages. Recent work has encountered a problem a lot of GIT. Recently I took over a project, the first time the source code uploaded to ...

Git everyday use Notes

Create a git repository Creating a branch Operation remote branch Version rollback   Reproduced in: https: //my.oschina.net/u/3398936/blog/1615916...

More Recommendation

[] Use git notes

Pull remote branch If you can not pull git project, may not be updated telematics...

Git use notes to organize

Reference article Install git Install git tortoise Set username and password $ git config --global user.name "xxx" $ git config --global user.email "[email protected]" Generate key ssh-ke...

One of the notes on the use of git

is very useful for a large project, especially for small partners who suddenly entered the project, or the project was not pulled from git at the beginning And everyone’s packaged projects were ...

git use notes 2

Transfer from: Liao Xuefeng's official website 1. Check the status of the workspace To keep track of the status of the workspace, use the git status command. If git status tells you that some files ha...

Git simple use notes

Preface Before learning Git, we have to know what Git is What is Git? Git is currently the world's most advanced distributed version control system (no one). What are the characteristics of Git? Simpl...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top