Changes between Version 53 and Version 54 of WorkingWithGit
- Timestamp:
- Sep 23, 2016, 6:01:47 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WorkingWithGit
v53 v54 46 46 which prompts you for the commit message. See the [#commitmessages section on commit messages in git] for more information on git conventions and expectations in commit messages. 47 47 48 Because of Git's distributed nature, a commit on your local machine is not immediately available on the central server, like it was the casewith Subversion. This means that you can continue to prepare further changes in additional commits before you publish your changes as a set. In fact, it is a very common practice in Git to do many small changes that are logically consistent in themselves and then publish them in one step.48 Because of Git's distributed nature, a commit on your local machine is not immediately available on the central server, like it was with Subversion. This means that you can continue to prepare further changes in additional commits before you publish your changes as a set. In fact, it is a very common practice in Git to do many small changes that are logically consistent in themselves and then publish them in one step. 49 49 50 50 If you have commit access, you can publish your commits using `git push <remote-name> <branch-name>`. `<remote-name>` is the name of the repository to which you want to push. The most common push target is the location you initially cloned, which is automatically named `origin`. `<branch-name>` is the name of the branch you want to push. The Git equivalent to Subversion's `trunk` is called `master`. It is considered best practice to always specify your push target and the branch you are pushing, since git's default is pushing all branches that have a remote equivalent when you run `git push`, which might publish changes that you do not consider final yet (you can disable this behavior by changing the `push.default` git-config setting to `nothing`, see [https://git-scm.com/docs/git-config git-config(1)]). … … 141 141 - To drop uncommitted modifications, use `git checkout -- <filename>`. If you had already added the file to the index using `git add`, you have to unstage it first using `git reset HEAD <filename>`. `git status` prints these commands, so you don't have to remember them. 142 142 - To undo a change that has already been committed and pushed, use `git revert <commitID>`. This will create a new commit that applies the inverse diff. Note that you still have to push this commit to publish it. 143 - To throw away all changes that you have locally committed but not yet pushed, use `git reset --hard origin/master`. '''You will lo ose all your uncommitted and committed modifications.''' If that is not what you want, Git provides a variety of tools that allow you to change commits that you have not pushed yet (and theoretically also commits that have already been pushed, which will prevent you from pushing any changes again). Since this is an advanced topic it will not be covered here. As a pointer for further research, look for `git commit --amend` to change the topmost commit and `git rebase --interactive`, the so-called "interactive rebase", to change older commits.143 - To throw away all changes that you have locally committed but not yet pushed, use `git reset --hard origin/master`. '''You will lose all your uncommitted and committed modifications.''' If that is not what you want, Git provides a variety of tools that allow you to change commits that you have not pushed yet (and theoretically also commits that have already been pushed, which will prevent you from pushing any changes again). Since this is an advanced topic it will not be covered here. As a pointer for further research, look for `git commit --amend` to change the topmost commit and `git rebase --interactive`, the so-called "interactive rebase", to change older commits. 144 144 145 145 … … 179 179 180 180 === Checking out a working copy of the ports tree === #cloneports 181 To get a working copy of the MacPorts ports tree to start changing ports, clone ofcopy of the repository:181 To get a working copy of the MacPorts ports tree to start changing ports, clone a copy of the repository: 182 182 {{{ 183 183 git clone git@github.com:macports/ports.git # or