-
Notifications
You must be signed in to change notification settings - Fork 61
Git FAQ
This page is broken down by use cases. Look for the heading that describes what you are trying to do, and follow the instructions.
- Go to: https://github.com/kframework/k
- Click the "Fork" button in the upper right, then select your personal account.
- In your git console, run
git clone
with the argument in the right sidebar on github. For example, Dwight runsgit clone https://github.com/dwightguth/k.git
. If you normally connect to git via SSH (e.g. because you want to specify an SSH key), you would use the SSH clone URL:git clone [email protected]:dwightguth/k.git
.
In order to simplify the process of manipulating changes, it is often very convenient to have a local branch named "master" which tracks "origin" and contains no local changes. This allows you to easily create new clean branches by running the command git checkout -b <branch_name> master
. These branches then contain your changes so that the "master" branch remains unmodified and in sync with the main kframework repository.
To create a new feature branch to commit your changes to, run the above command. However, if you already have made changes to your local "master" branch, it is advisable to move these changes onto a feature branch. To do this:
git checkout -b <branch_name> master # this creates a branch containing your changes so they are not lost when you rebase master
git checkout master # move back to master branch so that the following command works correctly
git reset --hard upstream/master # reset working copy and all local commits to the upstream/master which is clean
By making your changes only on branches of your local "master" branch, you simplify the process of merging, rebasing, moving changes between branches, etc.
- Log into github and click "Pull request" next to the line that says "This branch is commits ahead and commits behind master".
- If you are pulling into a branch other than master, make sure you click "Edit" at the top and then select that branch where it says "Base".
- Make sure you are submitting the correct change, type up a description for it, then submit it. This automatically emails everyone watching the K framework repository except yourself.
- If you need a particular user to review your change, you should tag their Github user ID in the pull request description. For example to ask me to review something you might say "@dwightguth Please review."
- At this point it becomes the responsibility of reviewers to comment on your change and either approve it or request modifications. They can do this by accessing the pull request online and commenting on the change or on specific lines of code. If they request changes, you can update the pull request simply by pushing further changes on the same branch to your fork. Once the pull request is approved, you are free to click the "Merge pull request" button on the bottom of the pull request screen to automatically merge and close the pull request.
- Note that any push made to the same branch after the pull request is opened but before it is closed will add that commit to the pull request. To continue working on a different change during that time period, you must work on a branch.
- Create a short-term feature branch in your fork by running the command
git branch <branch_name> <commit_id_to_branch_from>
. For example to create a branch named "foo" from the commit immediately prior to the most recent, you might rungit branch foo HEAD^
. For information on how to specify commits, seegit help revisions
- Switch to the new branch by running
git checkout <branch_name>
. - Start making your new change. When it comes time to perform a pull request, push the changes upstream to the branch you created by running
git push origin <branch_name>
. - Proceed from section "Create the pull request"
- (do this once) run
git remote add upstream [email protected]:kframework/k.git
(or use HTTPS if you prefer). This adds a remote repository to your local repository for the kframework/k repository. - Run
git pull --rebase upstream <branch_name>
to sync a particular branch with the main repository. Do this if your branch is behind the master repository.