Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Before reviewing this page, you should be familiar with concepts of version control and distributed version control systems. See /wiki/spaces/CONNECTWIKI/pages/8585251 for information and links.

Cloning the Repository

  • How do I clone the CONNECT git repository?

    Code Block
    git clone https://github.com/CONNECT-Solution/CONNECT <desired path>
    


...

  • How do I see all my branches?

    Code Block
    git branch (local only)
    git branch -r (remote only)
    git branch -a (all)
    


  • How do I "switch" to the 3.3.1 branch?

    Code Block
    git checkout 3.3.1
    


  • How do I branch and checkout using one line?

    Code Block
    git checkout -b 3.3.1_foo_bug_fix 3.3.1
    
    

    This is equivalent to:

    Code Block
    git branchcheckout 3.3.1_foo_bug_fix
    git checkout -b 3.3.1_foo_bug_fix
    


  • How do I delete a local branch?

    Code Block
    git branch -d 3.3.1_foo_bug_fix
    


  • How do I create a new "foo" tag on the "bar" branch?

    Code Block
    git checkout bar
    git tag "foo"
    git push origin tag "foo"
    


  • How do I create a new "foo" tag on a specific commit on the "bar" branch?

    Code Block
    git checkout bar
    git tag -a "foo" <commit hash> -m "<tag message>"
    git push --tags
    


  • How do I delete a remote tag?

    Code Block
    git tag -d <tag name>
    git push origin :refs/tags/<tag name>
    


  • How do I delete a remote branch?

    Code Block
    git push origin :<name of branch to delete>
    


  • How do I create a new branch and push to remote?

    Code Block
    git checkout <name of branch to base from>
    git branch <new branch name>
    git push -u origin <new branch name>
    

    The -u switch will automatically configure git to push and pull from the remote branch. You can leave off the -u switch if you don't want git pull to merge the remote branch to your local.

  • How do I see which local branch is tracking which remote branch?

    Code Block
    git remote show origin
    


  • How do I create a branch called 3.2.2_dev based off of a 3.2.2 branch from the server?

    Code Block
    git checkout -b 3.2.2_dev remotes/origin/3.2.2
    


  • How do I work with a tag based off of a branch (e.g. 3.2.2_RC2 tag based off of 3.2.2 branch)?

    Code Block
    git checkout 3.2.2      # checkout base branch
    git pull                # get latest remote base branch
    git checkout 3.2.2_RC2  # checkout tag
    


  • How do I work with a remote branch or other fork of CONNECT?

    Code Block
    git remote add connect_official https://github.com/CONNECT-Solution/CONNECT.git   # Add the repo to your remotes. Arguments are: git remote add <alias> <URL>
    git fetch connect_official                                                        # Fetch the changes so you can pull and checkout
    git remote -v																	  # List all of your remote repositories.
    git checkout connect_official/CONNECT_integration                                 # If you wish to check out the branch entirely
    git pull connect_official/CONNECT_integration                                     # Or if you wish to pull these changes into your own branch instead


...

  • How do I clean up all the unknown files in my workspace?

    Code Block
    git clean -f -d
    git clean -f -d -X (remove ignored files as well)
    


  • How do revert all my changes?

    Note
    titleWarning

    This will delete all your changes as no backups are created!


    Code Block
    git reset --hard
    


  • To revert a single file or deleted directory, do:

    Code Block
    git checkout HEAD <FILE>
    


Reverting

  • HalpHelp! I accidentally committed and pushed a file to github! How do I revert it?
    Like subversion, you have to revert the file locally and then commit it. The <commit-ref> in the command below can be the SHA-1 value or the HEAD

...

So rebase only before you are ready to push. Rebasing changes the commit hash due to the process of your commits effectively being undone, and repeated off of the HEAD of the branch you rebase, so be mindful when you attempt to rebase.

Pull Requests

...

(PR)

First, make sure that your commits have been pushed to your fork. Once you have done thisThen, visit the repository in question (CONNECT, Common-Types, CONNECT-Webservices) and visit go to the Pull Requests Tab.

Once at On the Pull Requests tab you , there will see be a list of all Open open pull requests, as well as the . There is also an option to create a new one via the " New Pull Request " button.

Image Added

Creating a new Pull Request

Upon clicking the " New Pull Request " button you will be taken to a change comparison page between 2 branches. You will need to click button, a change comparison page will be shown between the 2 branches. Click the "compare across forks" hyperlink in order to show a separate repository (this should be your fork off of CONNECT) for your comparison. The base repository should be CONNECT-Solution/<Project> and the base branch should be "CONNECT_integration" for the CONNECT project , (or "master" for both Common-Types and CONNECT-Webservices). You

Warning

 You should never merge directly into the master copy when merging into the CONNECT project, as our Continuous Integration (CI) is responsible for running tests on the CONNECT_integration branch before everything is pushed to master.

...

These tests ensures that the code works as intended and does not introduce any broken features. Once  Once you have selected your repository , you must then select the branch that contains your changes you wish to integrate. Once you do so, the changes should The changes will then be listed on the page and will show any addition additions and deletions to the code base. If Once, you are comfortable with these changes, press the " Create pull request " button.

Image Added


At this point the PR should be code reviewed by other peers. If a peer feels changes may be are needed they should will submit a review of "Request Changes" and . This review will list any changes and a reason for why the change(s) is requested. Once everyone has submitted an Approval review, the changes may be merged into the repository.

Merge the Pull Request

In order to merge the PR, you must select one of the 3 options: Create a merge commit, Squash and merge, or Rebase and merge. The default of these options is “Rebase and merge” which will rebase your commits to replace them at the end of the HEAD commit on the base branch. Creating a merge commit will simply merge the commits into the base branch. Squash and merge will condense all the commits in the PR into a single commit, and merge them into the base branch. Once you have decided on which of the 3 merges you wish to use, select the option and click the merge button. The changes will then be merged into the base branch and the PR will be closed.