wiki:GitLinuxPMI-HOWTO

Version 6 (modified by bss, 14 years ago) (diff)

Document git push and pull

Git Repository URLs

  • Read/Write? (requires shell access): ssh://linuxpmi.org:1022/srv/git/current

Other Git Introductions

Minimal git

Clone

git clone ssh://juri@linuxpmi.org:1022/srv/git/current openmosix

or

git clone git.linuxpmi.org:/srv/git/current openmosix

The first command you'll learn, but you'll only use it once per repository. This command pulls down all the data in the repository specified and generally prepares your system to work with that repository. The git-clone(1) man page has the gory details.

Add

git add my_new_file

Anytime you create a file, you use this command to tell git that it should begin change tracking on it. Git will record the current contents of the file in the "index", a sort of working area that's not tied directly to the file system. You will also run this command against an existing file that you've changed to record the new contents in the index.

Mv

git mv a_tracked_file another_tracked_directory

or

git mv a_tracked_file my_new_file_name

This command is used to notify git of moves or renames. Updates the index.

Rm

git rm im_a_gonner

This command tells git that a file is no longer part of the tracked tree. Updates the index.

Status

git status

Has git report on the differences between the tip of the current branch, the index, and the filesystem. It will list new files to be added to the tree, renames, removals, files that have changed that will be committed, and files that have changed but not recorded to the index. Generally you'll want to run this before a commit to confirm what you are committing.

Diff

git diff

or

git diff --cached

or

git diff HEAD

This is a far more detailed version of status whose output is a unified diff. A simple git diff tells you changes between the index and your working tree i.e. changes you haven't told git to record yet. The more verbose git diff --cached gives the difference between the index and the last commit i.e. the changes you'll scheduled for commit. Finally git diff HEAD gives the sum total differences between the filesystem right now and the last committed version.

Commit

git commit

or

git commit -a

or

git commit some_files that_were_changed

This command records changes to your local git tree, moving the head/tip forward. Git will open your $EDITOR so that you can enter a commit message (empty messages are not allowed) or you can specify one with the -m option. With no options (other than -m), changes already recorded to the index are committed. With the -a option, files that are tracked are committed even if their changes have not been recorded in the index. -a is short for all, but it doesn't track additions or renames so you may have to use other git commands to schedule those changes for commit even if you are using it. If filenames are specified, changes between the last commit and the working tree to those file are committed, completely bypassing the index.

Push

git push

git commit}} only records changes to your local repository, eventually you'll probably want to send that information back to the git repository you {{{cloned from. This command does just that.

Pull

git pull

Assuming you aren't the only one working from the repository you cloned from it will change from time to time. This command fetches the new data merges it into your local repository.

Branch Management Git

Branch

Checkout

Pull 2

Diff 2

Rebase

Other Git

.gitignore

By analogy: .cvsignore -> CVS <-> .gitignore -> git

Git refuses to track empty directories, but an empty .gitignore in a otherwise empty directory will convince it to check in the directory, just like CVS. Even the file format is the same.

Bisect

Cherry-Pick

Reset

Revert

Tag