[Git notes] git use notes

tags: notes

contents

First, pull the warehouse code, submit the code

Second, new, switch branch


First, pull the warehouse code, submit the code

1, pull the git project.

git clone [email protected]

2, submit the code process

Step1. View the project code which makes modifications

STEP2. Update the modified code; add

STEP3. Writing update log; commit

STEP4. Submit Update to Remote Warehouse;

### step1. View the project code which makes modifications
git status

 ### step2. Update the modified code;
 Git add. #. Represents all modified code
 Git add test.cpp # can also only update some of the modified code

 ### step3. Writing update log;
 git commit -m "update a certain function"

 ### step4. Submit update to the remote warehouse;
 Git Push Origin Master #Master indicates the name of the branch
 Git Push Origin Panda # indicates that the submission is updated to the Panda branch.

3. When submitting the code, it is found that the remote warehouse exists with the local inconsistent code. (Some people have submitted new code before you update)

Git Pull - Rebase Origin Master # step1. Don't pull a different branch of remote rush

 Git Push Origin Master # step2. Re-Push

Second, new, switch branch

1. View all current branch lists (Name Prior * Identification The current pointing branch)

### View Local Branch List
git branch

 ### View Remote Branch List
git branch -a

2, create and switch to the new branch:

git checkout -b chen

 ###Equivalent to: 
git branch chen
git checkout chen

3, submit the code to the new branch:

Git Push Origin XXX #xxx indicates the name of the branch

git push origin panda

4, merge branch:

### step1. Cut back to Master branch
git checkout master

 ### step1. Core Panda branch into MASTER
git merge panda

5, delete branch:

Git branch -d xxx #xxx represents the branch name

Third, pull the remote latest code forced overwriting the local code

git fetch --all && git reset --hard origin/master && git pull

The first is: pull all updates, do not sync;

The second is: the latest version on the local code synchronous line (will overwrite all the local files with the same name on the remote warehouse);

The third is: update again (actually no need, the second step is actually done)

 

Fourth, git jumps to the specified historical version

### step1. Pull the latest code:
git clone xxxxxx.git

 ### step2. Switch to the specified version:
 Git Checkout <commit sha> # here is the designated version of the CommMit number

 

Question:When Git Pull is prompted: You cannot pull it out of the change: you have unmissive changes.

reason:There is a modified content locally, but there is no Git Add.

solve:Step1. Use the contents of the Git Stash to temporarily change;

STEP2. Use git press --Rebase Origin Master pulls remote code;

Step3. Then push the code Git Push Origin Master.

Intelligent Recommendation

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   2. Cloning a remote server in the local repository git ...

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 ...

More Recommendation

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...

[] 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...

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

Top