You will perform three tasks in this exercise.
- Create and fix a merge conflict
- Amend a commit
- Create and approve a pull request
It is strongly recommended that you use a git extension for your IDE to complete this lab. If you are using Visual Studio Code, you can use the GitLens extension.
- Fork the PyTorch repository to your GitHub account.
- Clone the forked repository to your local machine by running the following command in the terminal:
git clone -n --depth=1 --filter=tree:0 <your repo url>
cd pytorch
git sparse-checkout set --no-cone torch/nn
git checkout
- Open the repository in your IDE.
- Create a new branch called
merge-conflictfrommainbranch. - Open the
torch/nn/functional.pyfile, navigate to theinterpolatefunction (line 3856) and change the resizing mode fromnearesttobilinear: - Commit the changes to the
merge-conflictbranch. Make sure you add a meaningful commit message. - Switch back to
mainbranch. - Open the
torch/nn/functional.pyfile, navigate to theinterpolate(line 3856) function and change the resizing mode fromnearesttobicubicandalign_cornerstoTrue: - Commit the changes to the
mainbranch. Make sure you add a meaningful commit message. - Merge the
merge-conflictbranch into themainbranch. - Resolve the merge conflict by keeping the resizing mode
bilinearandalign_cornersTrue. - Commit the changes to the
mainbranch. Make sure you add a meaningful commit message.
- Create a new branch called
amend-commitfrommainbranch. - In the
torch/nn/functional.pyfile, navigate to themulti_margin_lossfunction (line 3566) and change the margin to 1.5 and reduction mode to `sum' - Commit the changes to the
amend-commitbranch. Make sure you add a meaningful commit message. - Amend the commit by changing the margin to 2.0
- Commit the changes to the
amend-commitbranch. Make sure you add a meaningful commit message.
- Create a new branch called
pull-requestfrommainbranch. - In the
torch/nn/functional.pyfile, navigate to thel1_lossfunction (line 3308) and add code to check if the reduction mode issumand raise an exception: - Commit the changes to the
pull-requestbranch. Make sure you add a meaningful commit message. - Push the
pull-requestbranch to the remote repository. - Create a pull request to merge the
pull-requestbranch into themainbranch. - Approve the pull request.
- Merge the
pull-requestbranch into themainbranch.
git checkout -b <branch-name>- creates a new branch and switches to itgit checkout <branch-name>- switches to the specified branchgit merge <branch-name>- merges the specified branch into the current branchgit status- shows the status of the current branchgit add <file-name>- adds the specified file to the staging areagit commit -m "<commit-message>"- commits the staged changes with the specified commit messagegit log- shows the commit historygit log --oneline- shows the commit history with each commit on a single linegit log --oneline --graph- shows the commit history with each commit on a single line and the branches graphgit push origin <branch-name>- pushes the specified branch to the remote repositorygit pull origin <branch-name>- pulls the specified branch from the remote repositorygit branch -d <branch-name>- deletes the specified branchgit commit --amend- amends the last commitgit push origin --delete <branch-name>- deletes the specified branch from the remote repository