Development scenario:

  • A remote has a master branch that provides a formal stable version for users to use.

  • Development branch dev for daily development.

  • Developers can create their own Local branches locally, called Local branches.

  • Then push to the remote branch and merge to the remote branch dev.

Use the Version control tools of Studio

1. Configure Git (Android Sudio for MAC)

Android Studio has already configured the git installation location for Android Studio, which can be found on setup ->Version Contral-> git -> Path to Git executable.Copy the code

2. Enable Git management for the project this step is to put the project under Git management

After clicking VCS on the Android Studio menu bar, select Enable Version Control Integration. Select Git from the box that pops up.Copy the code

3. Switch to the Project view and right-click on Project

Select git-> Add from the list that pops up to put your project's files under Git management.Copy the code

4. Add the ignore file (in the project’s.gitignore) or download the plug-in (ignore right-click new.ignore file)

*.iml.gradle /local.properties /.idea.ds_store /build /captures /MPChartLib/bulid/ .externalNativeBuildCopy the code

5. Commit (up arrow) Configure the warehouse path login account password for the first time commit-> push

Use the command line

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — basic — — — — — — — — — — — — — — — — — — — — — — — —

Initialization: git init

Add all file controlled version control: git add.

Git commit -m ‘your word’

Git push Origin

Git pull from a remote location

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — branch — — — — — — — — — — — — — — — — — — — — –

Git branch ‘name’

Git push ‘origin’ (must match the local branch name)

Check local and remote binding status: git branch -vv

To view all branches: git branch -a

Git branch — set-uppage-to =’origin’

Git checkout ‘branch’

Git merge git merge

Synchronizing the dev branch log

  • ➜ project git:(ming) git checkout dev
  • Switched to branch ‘dev’
  • ➜ project git:(dev) git merge ming
  • Updating 7cf39b1.. 06e1529
  • Fast-forward
  • app/build.gradle | 32 ++++++++++———————-
  • app/src/main/AndroidManifest.xml | 3 +++
  • create mode 100644 app/src/main/res/layout/item_withdrawlist.xml
  • ➜ project git:(dev) git add.
  • ➜ project git:(dev) git status
  • On branch dev
  • nothing to commit, working tree clean
  • ➜ project git:(dev) git push origin dev
  • Total 0 (delta 0), reused 0 (delta 0)
  • To http://47.104.17.92/Ming/project.git
  • 7cf39b1.. 06e1529 dev -> dev
  • ➜ project git:(dev) git log

Update:

— — — — — — — — — — — — — — — — — — — — not so commonly used — — — — — — — — — — — — — — — — — — — — — — — — —

Git branch (* indicates the current branch)

To view all remote branches: git branch -r

All local and remote branches: git branch -a

Git status

— — — — — — — — — — — — — — — — — — — — — — — the tag related — — — — — — — — — — — — — — — — — — — — — — — — — — —

Git tag ‘tagName’

View all tags: git tag

Git tag -d ‘tagName’

Git push origin ‘tag’ to remote repository

Git push origin -d ‘tagName’

Reference: List of common Git commands

Add… The current basic can meet most of the needs.


The 9.1 update

D:\Space\AndroidProject\Base>git remote -v
origin  https://gitee.com/1806613533/Base.git (fetch)
origin  https://gitee.com/1806613533/Base.git (push)

D:\Space\AndroidProject\Base>git remote remove origin

D:\Space\AndroidProject\Base>git remote -v

D:\Space\AndroidProject\Base>git remote add origin https://gitee.com/1806613533/Base.git
Copy the code

Git remote -v

Git remote remove origin Specifies the remote address to be removed

Git remote add origin git remote add origin

—————– Add SSL key ———————

ssh-keygen -t rsa -C “[email protected]

cat ~/.ssh/id_rsa.pub

➜ bit-z_and git: Ming) Those who qualify can go onto ssh-keygen -t rsa-c “[email protected]”.

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/mrming/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /Users/mrming/.ssh/id_rsa. Your public key has been saved in /Users/mrming/.ssh/id_rsa.pub. The key fingerprint is: SHA256:U7uTbgTtbINDJYsDLuDutR9eA7wWb82bj8a27viJ+NA [email protected] The key’s randomart image is: +—[RSA 2048]—-+ | | |. . . . | |.. … =. | |.. o o +… | |. . + oS=. | | . . * =.o | |. . .= E.+. | | . .o * +=. | | .+.+@+. | +—-[SHA256]—–+

➜ bit-z_and git: Ming) Qualify cat ~/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDzzfF0CbytS72kR8ejXN7MKO/DeyET4kwohCWlCMGFHMiyOSuuhBd0mhB6HsurdJ50nBNlJXmHw9lbQSqfy0b5iTST 3+/Wc8hQADFJOkPNWx3uKCWSzK3TfNm+NNxJi4p7QksibEi5wsiX5uCLBQj86Ye7SzKuOLph9aR6Un5KOaXkl2fa4xXPz7 [email protected]


Git error:

If both remote and local commit leads, this is where your error occurs. Simply delete or add -f the specified file.

Add -f indicates to forcibly add a file. For example, a.txt file is in the ignored file path. Add -f indicates to force the operation

About conflict resolution: the content in the middle from <<<<<<< HEAD to ======= is submitted by local.

======= to >>>>>>> are the contents of the remote repository

The new 11.22:

I am currently in the dev branch and want to use the qin branch code to completely override dev with the following command:

Git fetch --all git reset --hard origin/qinCopy the code

Deleting a Local Branch

 git branch -d <BranchName>
Copy the code

Deleting a Remote Branch

 git push origin --delete <BranchName>
Copy the code

Force push command

git push -u origin master -f
Copy the code

You are not allowed to force push code to a protected branch on this project.

Solution: Access the website and choose Settings > Protection Branch > Cancel protection. Can be