Site
Site
文章目录
  1. Git operation
  2. Put your project into remote warehouse
  3. Change your git warehouse address
  4. Submit code steps
  5. Resolve git conflict
  6. Merge conflict
  7. Rebase conflict
  8. Some Matter In Work

Git Notes

Git operation

Put your project into remote warehouse

1.you need a project code and a code repository(gitHub or coding)

# 1.initialize local repository
$ git init

# 2.add the project code to working tree
$ git add .

# 3.commit your project code
$ git commit -m "first commit notes"

# 4.synchronize the code to the remote repository
$ git remote add origin your remote reposiroty address

# 5.synchronize the code to the remote repository
$ git push -u origin master

Change your git warehouse address

We use the simplest method.

git remote set-url origin remote_git_address

Submit code steps

# 1.add your code to the working tree
$ git add .

# 2.commit your code with message
$ git commit -m "notes"

# 3.pushed to the remote branch
$ $ git push origin yourBranch

# 4.switch to the dev branch 
$ $ git checkout dev

# 5.synchronize remote dev branch code
$ $ git pull

# 6.merge your branch code into dev
$ git merge --no-ff -m "merge: notes"

# 7.pushed to the remote branch
$ git push

# 8.switch to your branch
$ git checkout yourBranch

# 9.rebase the dev branch
$ git rebase dev

# 10.pushed to the remote branch
$ git push origin yourBranch

Resolve git conflict

Merge conflict

1.find the conflict file
2.find the text like this

<<<<<<< HEAD  -- dev branch
 dev code
=======
your code
>>>>>>> 6853e5ff961e684d3a6c02d4d06183b5ff330dcc  -- your branch

3.remove the conflict flag, leaving only one branch of the code (dev code or your code)
4.add changes to the working tree

$ git add .

5.commit your code

$ git commit -m "notes"

6.push changes to dev branch

$ git push

Rebase conflict

1.find the conflict file
2.find the text like this

<<<<<<< HEAD  -- dev branch
dev code
=======
your code
>>>>>>> 6853e5ff961e684d3a6c02d4d06183b5ff330dcc  -- your branch

3.remove the conflict flag, leaving only one branch of the code (dev code or your code)
4.add changes to the working tree

$ git add -u

5.continue rebase

$ git rebase --continue

6.until all conflicts resolved
7.if you want to quit rebase

$ git rebase --abort

attention: after rebase,don`t need to commit and submit new changes,all git automatically

Some Matter In Work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
*.classpath
.factorypath
*.project
*.settings/
*.springBeans
*.class

### IntelliJ IDEA ###
*.jar
# *.war
*.ear
*.log
*.mvn

*.idea
*.iws
*.iml
*.ipr

target
src/test

### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

need to remove cached first :

git rm -r --cached .

no userName no password every push :

git config --global credential.helper store

if the 22 port is refuse always :

# check remote url
git remote -v

# then update it to http like this
git remote set-url origin http://[yourGitUserName]@test.com/test.git

# check again
git remote -v

# then push or pull with password
支持一下
扫一扫,支持xfan
  • 微信扫一扫
  • 支付宝扫一扫