Git usage (new branch), gitbranch

Source: Internet
Author: User
Tags how to use git

Git usage (new branch), gitbranch

Create new branch and view all branch (kk code is based on existing branch)


Switch to branch kk:


Of course, we can also operate in android studio:



Note that the Code will be lost when switching. You must commit the code before switching.


If the local code conflicts with the server, an error occurs during pull:


We must stash Changes, update completely and then unstash changes


Generally, we need to perform the pull operation before pushing the code.




How does git create feature? What is the difference between it and branch?

Before explaining what git is, we need to give a basic overview of Version Control. Generally, our source code is managed and maintained in two dimensions: Time and Space. The Code itself and the project files that organize the code (such as makefile or vs project files) they are stored in disk space in the form of files and directories. This form of file management is already familiar to everyone. However, how can we manage various changes made in different time periods? Version Control System (VCS) is a System that records the evolution of code modifications. Its function is to help you retrieve a specific timing period (or Version) in the future) file, view the changes between versions, compare the changes, or fix the fatal errors.
 
How to Use git to create a project and a branch

Git config-global user. name "Your name" git config-global user. e-mail "you@example.com" creates a folder for storing the project git init command used to initialize the current directory of this project will create a hidden file. git creates main. c file creation. the gitignore file ignores the project file git status in the file to view the project status git add .. create a snapshot for my current project (the snapshot is only registered with the name, the snapshot is not equal to the record, the snapshot is called the index) git commit is used to permanently write the content registered in the snapshot to the git repository, that is, the developer has prepared to submit his own development results. Note: When writing development logs, the first line must be a general development information of less than 50 characters, and the second line must be empty lines, the third line starts to describe the development information in detail. This is because the email mechanism in many version service systems selects the first behavior email question in log. The git commit-a command can directly submit all the modifications, saving you the steps of git add, git diff, and git commit. Note: you cannot add new files or folders. Therefore, if you have added files or folders, You have to honestly add them first ., git commitgit log-p. If you think the information provided by git log is too thin, you can use git log-p, so that git will not only provide development logs, the Code differences for each development version are displayed. Conclusion: First add the file you modified by git, then git diff and git status to check and confirm, then commit by git commit, then enter your development log, and finally confirm the git log again. Create branch git branch experiment create a branch directly input git branch without any subsequent parameters, it means let git list all existing branches. The branch with an asterisk (*) indicates the current branch. Switch branch to experimentgit checkout experiment branch program OKgit commit-a submit a job on the branch switch to master git checkout mastergit commit-agit merge experiment merge branch to main road prompt merging failure View Source File git confusion it does not know whether to put the hello world line in front or the time report function in front.

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.