Git common commands and androidstudio common shortcut keys

Source: Internet
Author: User
Tags try catch git commands git mergetool

GIT-related content:

Generate key:
CD ~/.ssh (C:\Users\ account name \.ssh)
Generate key: Ssh-keygen-t rsa-c "[Email protected]"
Enter on the line. Then, you will be prompted to enter the password, as follows (recommended to lose one, a little safer, of course, do not lose):

Add a public key to your GitHub account:
1. Log in to your GitHub account. Then on the left column of account Settings, click SSH keys, click Add SSH key
2, then you copy the above public key id_rsa.pub content, paste into the "key" text field. Title field, you can just fill in a line.
Click Add Key to verify: ssh-t [email protected] (git address)

git commands
git branch-va View Branches
git branch-l local branch-R View Remote branch,-a view all branches
git checkout-b Dev origin/dev switch Create branch Dev, associate to this branch
git checkout-b [branch name] [remote name]/[branch name]

Create a branch
Git checkout-b feature_name origin/master create a new branch based on the Origin/master

Switch branches
If you have more than one branch, you can switch to a branch with checkout. The usage is simple:
git checkout Branchname

The above command, if added with the parameter branch, will increase the function.
git checkout branchname--FilePath

git Fetch updates Remote library change content
GIT fetch < remote host name > < branch name >
Git fetch Origin Master

git merge
When merging branches, GIT uses fast forward mode if possible, but in this mode, the branch information is discarded after the branch is deleted.
If you want to force the fast forward mode to be disabled, GIT will generate a new commit at merge, so you can see the branching information from the branch history.
Git merge--no-ff-m "merge message" Dev


Git status
View the status of the repository. To know which files have changed and which files have not been added to the GIT library
git diff filename to see what's changed

git reset fallback
git reset--hard head^ fallback previous version
git reset--hard 2e70fdf fallback specified version

Modification and Revocation

Use git diff HEAD--readme.md to see the difference between the latest version of the workspace and the repository.
Git checkout--file can discard modifications to the workspace
Example: Git checkout-readme.md means that the readme.md file changes in the workspace are all revoked, that is, the file back to the last git commit or git add, when the state, mistakenly deleted file recovery.
Of course, you can also use the git reset command.

git log
git log--pretty=oneline log simplifies display
git log--graph--pretty=oneline--abbrev-commit branch Merge History
Git reflog view connit ID record History
git log--stat

Git pull push
Git pull Origin Dev remote branch to this branch

Create + Switch branch: git checkout–b name
Merge a branch to the current branch: git merge name
Delete local branch: git branch–d name
Delete a remote branch
Git branch-r-D origin/hongchangfirst
To really delete the content on the remote branch, you can:
git push Origin:hongchangfirst
Note that the white space in front of the colon is not small, equivalent to pushing an empty branch to the server, which is equal to deleting the branch

Git stash function, you can put the current work site "storage", and so on after the resumption of the site to continue to work:
Another way is to use git stash pop, restore the stash content also deleted
You can stash multiple times, start with Git stash list, and then restore the specified stash
' Git stash apply [email protected]{1} ' to remove your specified version number as [email protected]{1}, stash content is not deleted, use git stash drop to delete


Branch switching, updating issues
Esc,esc.
: q! Enter


View remote repositories: $ git remote-v
Add remote repository: $ git remote add [name] [url]
git remote add teamCenter http://git.ihangmei.com/AndroidTeam/WangFanApp.git

Delete Remote repository: $ git remote RM [name]
Modify remote repository: $ git remote set-url--push [name] [Newurl]

Git commit-am "<message>"
Git commit-a
It has been added to the stage via git add <change file> and can be commit-m through git, "<message>" your file has been submitted before, but this change has not yet entered the stage
Git push-u origin Resourcecodeclean

Usually when we commit to git, it's all
git Add.
git commit-m "some str"
git push

These three big strides, and in fact, you only need two commands to be enough, unless there are new files to be added.
git commit-am "some str"
git push


Conflict resolution
File (for example, a user renaming a file to a a.c,b user renaming the same file to B.C, then B will merge these two commits, it will create a conflict)
If you finalize with B.C, then the solution
git rm a.c
git rm origin-name.c
git add B.C
Git commit

Content conflicts
When the merge conflict occurs, enter
Git mergetool
Differmege
http://blog.csdn.net/u010232305/article/details/51767887
git config--global merge.tool diffmerge

Update failure error
Fatal:refusing to merge unrelated histories
The latest version needs to be added--allow-unrelated-histories
If our source is Origin and the branch is master, then we need to write Git pull origin master----allow-unrelated-histories

Remove Build Directory
git rm-r--cached app/build Delete directory
Git commit-m "rm app/build"
git push
In. Gitignore, add the Ignore file App/build, or git checkout. Gitignore

Reference
http://blog.jobbole.com/78960/
Http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 0013752340242354807e192f02a44359908df8a5643103a000
git remote operator
http://blog.csdn.net/joelovegreen/article/details/42913163
Http://www.cnblogs.com/dubuqingfeng/p/201503-git-fork-synchronized.html



androidstudio shortcut key section
ALT + Enter import package, auto fix
ALT + Insert override method, using the template method
Ctrl+shift+j can integrate one row into two lines
Ctrl + O View class method equivalent to eclipse outline functionality
Shift double-click find Items 2 times to specify a class file
Ctrl+shift+space code hints quite eclipse alt+/
ctrl+/or ctrl+shift+/Comments (//or/*...*/)
CTRL+J Automatic Code
Ctrl+e recently opened files
CTRL+H Display class structure diagram
Ctrl+alt+b go to the implementation of the method
Ctrl+b: Jumps directly to the place where the class, method, member variable is defined. Same as CTRL + Mouse left button effect
Ctrl+alt+l Formatting Code
Ctrl+alt+o Optimizing imported classes and Packages
Ctrl+r replacing text
Ctrl+f finding text
Swap two lines of code
Ctrl+shift+ Arrow

Shift+f6 Refactoring-Renaming
ALT+F1: Quickly open project view, structure view, and more to see the appropriate elements.
Ctrl+tab: Open Interface Toggle Window

Ctrl+f12 class Method Lookup
CTRL+SHIFT+F Global Lookups
Control + N class file Lookup
Control + Shift + N file Lookup
F4/control + Enter Jump Source
Control + G Jump career
Shift + F4 Open the current editor in a new window

Ctrl+y Deleting rows
Ctrl+shift+u Uppercase and lowercase conversions
Ctrl+alt+l Code Formatting
Ctrl+alt+t surround code Try catch for etc

Ctrl+numpad-Folding
Ctrl+numpad + Expand
ctrl+alt+ (+,-) entire file

Build and run
Control + F9 Build
Shift + F10 Build and run
Ctrl + Alt + M Specify a code block to put in a new method

Studio inside the library, found that R has not been quoted
Build->make Module "Yourlibrary" and found that R.java generated a

Related source
Open the C:\Users\ user. Androidstudio2.1\config\options this path, find jdk.table.xml this file

Package Name Modification
CTRL + ALT + L (win/linux)
Has started developing with Android Studio. In Eclipse I is using ctrl+shift+f but in the Android studio it does not work, it'll be different.

To rename the application package method:
You can does this:
Change the package name manually in the manifest file.
Click on your R.java class and the press F6 (Refactor->move ...). It would allow you to move the class to the other package, and all references to that class would be updated.

Gradle production of the same program, different packgename methods
http://blog.csdn.net/chenaini119/article/details/46874241
productflavors{
flavors_release{
Manifestplaceholders = [str: "Releasestr", Package_name: "Com.example.android.newsreader"]
ApplicationID "Com.example.android.newsreader"
}

flavors_dev{
Manifestplaceholders = [str: "Devstr", Package_name: "Com.example.android.newsreaderdev"]
ApplicationID "Com.example.android.newsreaderdev"
}
}
In the Gradle panel on the right side of Android studio, click the button to refresh, so in the build sub-column
Where the assemble* starts with the APK option, the APK is generated in build/outputs/apk, where we can double-click to generate the corresponding APK
The apk corresponding to flavors_release and Flavors_dev should be the same as these two, then double-click them to wait for their own apk generation process

Reference:
Https://developer.android.com/studio/intro/keyboard-shortcuts.html
Http://developer.android.com/sdk/installing/studio-tips.html
Basic Setup http://www.imooc.com/wenda/detail/240863

Git common commands and androidstudio common shortcut keys

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.