Perform the following steps to download the code in the repository:
Create a local working directory to facilitate local code search and management.
mkdir /YOUR_PATH/src/gitee.com/${your_working_dir}
Note: If you have contributed to openEuler repositories, the created working directory will become a subdirectory of your existing gitee.com directory.
Set the Git user name to your Gitee ID.
git config --global user.name "your Gitee ID"
Configure the Git email.
git config --global user.mail "email@your_Gitee_email"
ssh-keygen -t rsa -C "email@your_Gitee_email"
cat ~/.ssh/id_rsa.pub
On the Gitee page, click your avatar in the upper right corner and choose Settings below your avatar to open the personal settings. Under Security Settings, click SSH Keys. In the Add Key area, add the SSH public key obtained by running the cat
command.
Authenticate your local SSH client with Gitee.
ssh -T git@gitee.com
If the following information is displayed, the SSH public key has taken effect:
Hi $user_name! You've successfully authenticated, but GITEE.COM does not provide shell access.
mkdir -p $working_dir
cd $working_dir
The openEuler community consists of multiple organizations. Check the name of the organization that the remote repository belongs to before cloning.
Copy the address of the remote repository as $remote_link for cloning the repository:
Run the following commands to clone the repository:
# Clone the forked repository
git clone https://gitee.com/$user_name/$repository_name
# Add the upstream remote (upstream repository of your forked repository) to the local working directory.
git remote add upstream https://gitee.com/openeuler/$repository_name
# Set the synchronization mode.
git remote set-url --push upstream no_push
Update your local repository.
git fetch upstream
git checkout master
git rebase upstream/master
Create a branch.
git checkout -b myfeature
Edit and modify the code on the myfeature branch.
For details about how to build locally, see the related documents provided in the repository. For details about how to obtain the documents, see this section.
# While on your myfeature branch
git fetch upstream
git rebase upstream/master
When merging branches, do not use git pull
to replace the fetch
and rebase
commands above. This is because it makes the commit history confusing and code difficult to understand. You can also modify the .git/config file to change the default behavior of git pull
by running the git config branch.autoSetupRebase always
command.
Commit your changes.
git add .
git commit -m "Reason for the commit"
You may continue to edit the build and perform more tests based on the previous commit and run the commit --amend
command to add more content to it.
When your changes are ready to be reviewed (or you want to establish a remote backup of your work), push the branch to your forked repository on Gitee.
git push -f origin myfeature
Visit your https://gitee.com/$user/$repository page.
Select the branch you used when committing your changes, for example, myfeature, and click + Pull Request, as shown in the following figure.
On the Create Pull Request page, confirm the source branch and target branch, and click Create Pull Request.
A pull request (PR) merges changes into the main project repository. To ensure the quality of the changes to be merged, exercise caution when creating a PR. For details about how to create a PR, see Pull Request Submission Guide. In this way, the PR you created can be correctly and quickly responded to and merged.
If you have write access to the upstream repository, do not use the Gitee UI to create a PR because Gitee will create a branch of your PR in the upstream repository.
After you create a PR, the PR is assigned to one or more reviewers. The reviewers will conduct thorough code reviews to ensure the correctness of the committed changes, including the code, comments, and documents.
You can find your PR in the PR list and view the review comments on the PR.
Small PRs are easy to review. Large PRs may not be correctly reviewed.
To revert a commit, follow the steps below.
If you have write access to the upstream repository, do not use the Gitee UI to create a PR because Gitee will create a branch of your PR in the upstream repository.
Create a branch and synchronize it with the upstream repository.
# create a branch
git checkout -b myrevert
# sync the branch with upstream
git fetch upstream
git rebase upstream/master
Run either of the following commands according to the type of the commit you want to revert.
For a merge commit:
# SHA is the hash of the merge commit you wish to revert
git revert -m 1 SHA
For a single commit:
# SHA is the hash of the single commit you wish to revert
git revert SHA
A new commit is created to revert the previous commit. Then, run the push
command to push the commit to your remote repository.
git push ${your_remote_name} myrevert
The following mark indicates that your PR conflicts with the main repository. You need to resolve the conflict.
git checkout master
git fetch upstream
git rebase upstream/master
git checkout yourbranch
git rebase master
The conflict message is displayed in the Git output. You can use tools such as vi
to view the conflict.
After the conflict is resolved, commit the changes.
git add .
git rebase --continue
git push -f origin yourbranch
Multiple commits in a PR can cause inconvenience to reviewers. After you modified the code in a PR based on the PR review comments, you can squash the commits If you do not want the reviewers to see multiple commits.
git log
git rebase -i HEAD~n
Change pick before the commits to be squashed to s, which is the first letter of squash. Note that you must pick at least one commit. Otherwise, there is no commit to be rebased onto, causing an error.
After the modification is complete, press Esc and enter :wq. The page for squashing the commit messages is displayed. Delete or edit the commit messages as required. Then, press Esc and enter :wq to save the modification and exit.
Push the commit.
git push -f origin yourbranch
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )