Version 5 (modified by neverpanic (Clemens Lang), 8 years ago) (diff) |
---|
This page should contain information about how to work with git, specifically from the point of view of someone familiar with Subversion.
Common git
tasks while working with ports
To start:
svn checkout https://svn.macports.org/repository/macports/trunk/dports
becomes
git clone git@github.com:macports/ports.git
When you clone you will get the entire history of the ports tree, with the latest version being checked out in the filesystem.
After you make a change, you can run git status
and get something like this.
On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: aqua/iTerm2/Portfile no changes added to commit (use "git add" and/or "git commit -a")
What this tells me, is that I've changed a Portfile, but not done anything.
After that, you can add the files that you want to add to your commit using git add aqua/iTerm2/Portfile
.
Now, git status
will look like:
On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: aqua/iTerm2/Portfile
Then run git commit
and everything is set. On your machine. To push to github you then have to run git push
.
Common git
tasks while working with MacPorts base
Checking out a working copy
The source code of MacPorts itself is no longer managed in the same repository as all ports. Contrary to Subversion, checking out a sub-directory of a repository is not possible with Git. In order to avoid that all port maintainers have to clone the complete history of MacPorts base as well, the Subversion repository has been split into multiple separate repositories. MacPorts base is now available using
git clone git@github.com:macports/base.git # or git clone https://github.com/macports/base.git # if SSH does not work on your network
See the section on repository splitting during the export to get an overview of where a path in the old Subversion history is now available in Git.
Committing changes in your working copy
A fundamental difference between Subversion and Git working copies is that svn commit
by default commits all changes in your working copy, but git commit
by default commits none. Git uses a staging area called "index" that allows you to mark changes for inclusion in the next commit. To add changes to the next commit, use git add <filename>
. git status
gives you an overview of the current index and your working copy. Additionally, it lists the commands to revert local uncommitted modifications (git checkout -- <filename>
) and to remove files from the next commit, but preserve the modifications in your working copy (git reset HEAD <filename>
).
Once you have chosen which files to include in your next commit using git add
, it is a good practice to review this list using git status
and show the diff to be committed using git diff --cached
. When you are satisfied with your changes, run git commit
, which prompts you for the commit message. See the section on commit messages in git for more information on git conventions and expectations in commit messages.
Common git
tasks & notes about MacPorts' Subversion export
Commit messages
WIP
Repository split
WIP
Attachments (1)
-
commit-history-with-excessive-merging.png (345.7 KB) - added by neverpanic (Clemens Lang) 8 years ago.
Attach picture that shows the result of excessive merging
Download all attachments as: .zip