Bitbucket and git for code management

Source: Internet
Author: User

Bitbucket is a very good open-source, free website that can host private code. In contrast, gitbub can only be open-source code hosted.

Install git and skip (you can use port or yum for installation)

After installation,

Apply for a free personal code hosting on the Bitbucket. You can also join 5-8 friends to form a team. If more people need to establish a Team for management.

Git is easy to use.

Simple Example:

Cd ~

Mkdir gitrepos

CD gitrepos/

Git clone https: // youname@bitbucket.org/yourname/myrepo. Git

Vim readme

Git add readme

Git commit-M "adding repo instructions"

Git push-u origin master

// The above is not explained. The common scenario is described below.

1. modify the code

Git pull first to ensure the current code is up to date

Modify the file. Right-click the file in xcode and select soucrer-> commit selected files. Submit the file to the local repository. Here, you can modify multiple files and submit multiple Local repositories.

Finally, input git push to complete the upload.

2. Add a new file

Similarly, first use git pull to ensure that the local code is up-to-date.

After adding a file, the project in xcode needs to be changed. Right-click the modified file and select Source-> commit selected files to submit the file to the local repository.

If your file is not a code file in xcode, for example, you can add another file named .docx, run the GIT add .docx command and enter git commit-M "this is the comment content". You can use Chinese characters.

Finally, input git push to push it up.

3. Modify the non-code file. For example, modify the file "...docx ".

After modifying the Word file locally, enter git commit-M. This is the first time you have modified this file.

Enter git push to complete the modification.

4. to add an empty folder to the project, follow these steps: Create a folder in the physical location, import the folder in xcode, and then execute git status, git does not detect anything. This may be a small bug in git. Git cannot detect empty folders, So we add another file to this folder, then execute git status, and git will show that there are files not tracked, So git add folder1/folder2, and then input git commit-M "comment". After the execution, git prompts you to add another file, and finally git
Push, and then go to the server.

5. if some files or folders in the project do not need to be uploaded to the server or shared with others, you can edit them in a hidden file under git, to specify which files do not need to be included in git for management, use the terminal console and enter vim. gitignore (the premise is to enter the current folder. Because git stores all the records under the top-level directory, CD is required first to the top-level directory .), Edit the directory, such as magazineuniteoldqikan/magazinepro/201203. Then save it. When you execute git again
Status, the 201203 folder specified in the current directory is not counted by git.

However, one error occurred, that is, in the first line of the. gitignore file, I added a blank line. As a result, the file seems to have expired. After deletion, the system still fails. Later, it executes git reset head ^ and then it becomes normal. The cause is unknown. It may be that the file cannot be empty.

6. record a problem. When executing git pull, SSH: connect to host 121.199.240.201 port 22: Connection refused, fatal: cocould not read from remote repository is displayed. please make sure you have the correct access rights and the repository existed. of course, we found that this server is normal, so we thought it was possible that the company port was disabled,
I asked it.

7. If you want to reset a file, you can execute the GIT reset head file name and then execute the GIT checkout file name. This usually occurs when project files used in xcode conflict.

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.