BitBucket and git for code management

Source: Internet
Author: User
Tags commit reset git clone

BitBucket is a very good open source, free and able to host private code site. By contrast, Gitbub can only be managed with open source code.

Install Git, skip (can be installed using port or yum)

When the installation is complete,

Apply for a free personal code hosting on BitBucket, this can also add 5-8 friends to form a team, if more people need to build teams to manage.


Git is very easy to use

A 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 does not explain, the following talk about the commonly used scenario

1. Modify the Code

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

Then make the modification, after modifying, right-click the file in Xcode, select Soucre---Commit selected files. Submit to the local warehouse. Here you can complete the modification of several files and submit multiple local repositories.

Finally, enter git push to upload, which is done.


2. Add a new file

Also, git pull first to ensure that the local code is up-to-date

Add files, usually after adding files, Xcode Project Engineering will need to change, and then the same as above, right-click on the modified file, select Source->commit selected files submitted to the local repository.

If the added file is not a code file in Xcode, if you need to add another "hello. docx" file outside, then use the command git add everyone good. docx, and enter Git commit-m "This is the comment content", you can use the Chinese

Finally, enter git push to push up.


3. Modify non-code files, if you need to modify a "good everyone. docx" File

After you have modified the Word file locally, enter Git commit-m "This is the first time you've modified it." Docx

Then enter git push to complete the modification


4. If you want to add an empty folder in the project, the operation is as follows: first create a folder in the physical location, then import this folder in Xcode, and then execute git status, you will find git nothing detected, this may be a small git bug, git can not detect empty folders, So we add a file in this folder, and then git status, Git will show that the file is not track to, so git add folder1/folder2, and then enter the git commit-m "comment", after the completion of the GI T prompts you to add a different file, the last git push, and then the server.


5. If some files or folders in the project do not need to be uploaded to the server and do not want to share them with others, you can edit them in a hidden file under Git to specify which files do not need to be managed in Git, by entering VIM via terminal console. Gitignore (If you go to the current folder, because Git puts all the records in the top-level directory, you need a CD to the top-level directory first.) ), and then make edits that can be relative to the directory location, such as the magazineuniteoldqikan/magazinepro/201203 typeface. Then save, when you execute git status again, you will find that the 201203 folder specified in the current directory is not counted by Git.

But there was a mistake, in this. gitignore file, the first line, I added a blank line, and as a result, the file seems to expire. After the deletion or not, and then executed the git reset head^, and then normal. The reason is unknown, perhaps this file can not be blank line.


6. Log a problem encountered when executing git pull, display ssh:connect to host 121.199.240.201 Port 22:connection refused, fatal:could not read from Remote Repository.  Please make sure the correct access rights and the repository existed. Of course we found that the server is normal, and then thought it might be the company this port is banned, asked about it, sure enough.


7. Sometimes a file wants to be reset, can execute git reset HEAD file name, and then execute git checkout file name, can. This is usually used when the project file in Xcode conflicts

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.