Skip to content

Reference (GIT)

spraggettMG edited this page Jul 24, 2024 · 2 revisions

1. To clone the repository, the recurse submodules will clone all submodules

git clone --recurse-submodules <repository>

2. Update the repository to the latest state, includes all possibilities

git submodule update --init --recursive # Gets all submodules up to date
git fetch # Pulls all remote branches onto all local branches
git pull  # Pulls the remote branch of the same name onto the local branch of the same name

3. Clean repository of all changes, not including already committed files

git checkout -- origin/remote-branch * # Where remote-branch is the branch you are currently on

4. Clean repository of all changes, including already committed files

git reset --hard
git clean -fd
git submodule sync
git submodule update

5. Stage changes to file1 and file2 and commit to remote branch

git add file1 file2 # Use git add . to add all files
git commit -m "Added file1 and file2"
git pull # In case the remote branch is ahead of the local branch
git push origin remote-branch # Where remote branch is the name of local branch

6. Merge changes from a different branch into the current branch

git pull origin <different-remote-branch>
git mergetool # Or use IDE to merge
git add .
git commit -m "Merged branch from different-remote-branch"
git push origin original-remote-branch

7. Create a new branch from original-branch

git fetch # To make sure you have the latest
git checkout origin original-branch
git checkout -b origin new-branch
git status # You should now see yourself be on the new-branch

8. Create a pull request from current remote branch to another remote branch

  • Go to github.com/utra-robosoccer/
  • Click on pull request
  • Click on new pull request
  • Select the branch you want to merge with, (ideally you merge from custom branch to master branch)
  • Add the users reviewing the merge and update all of the fields on the left

MISC

remove submodule https://gist.github.com/myusuf3/7f645819ded92bda6677

Setup private repo from a public, look at second answer https://stackoverflow.com/questions/10065526/github-how-to-make-a-fork-of-public-repository-private

Adding submodule https://git-scm.com/book/en/v2/Git-Tools-Submodules

Clone this wiki locally