User Tools

Site Tools


git:git_cheatsheet

This is an old revision of the document!


GIT CheatSheet

Mark file as 'unchanged'

This will ignore the file on all commits using the -a argument.

git update-index --assume-unchanged [file]

To include the file in commites again use:

git update-index --no-assume-unchanged [file]

This is particularly handy when making local changes to a config file that must not enter the central repository.

List current status (including changes) in repo

git status

List files in repo

git ls-files

List deleted files in repo

git ls-files -d

Undelete file

git checkout filename

Undelete all deleted files

git ls-files -d | xargs git checkout --

Mark conflict as resolved

filename will have merge conflicts marked in the same way used in CVS.

git add filename

marks the conflict as resolved.

Turn off pager

git --no-pager [command]

Run

alias git='git --no-pager'

to disable it on all commands in the current shell. Alternatively set core.pager = in .gitconfig (it is set to the empty string.) to disable it entirely for that user.

Tags

Create

git tag -a v1.4 -m 'version 1.4'

List

All:

git tag

Or filtered:

git tag -l v1.*

Show

git show v1.4

Push

By default, the ‘git push’ command will not transfer tags to remote servers. To do so, you have to explicitly add a –-tags to the ‘git push’ command.

Branches

List branches

git branch

Switch to branch

git checkout [branchname]

CVS 2 GIT

git cvsimport -k -i -d server:/path/to/CVSHOME -C git_reponame cvs_reponame

The resulting git_reponame directory now contains the .git folder which can be moved to a server location for shared access. Run git update-server-info in the new server folder in order to make it shareable.

Branching/Merging

Creating a new repository

As root:
mkdir /home/git/repos/[reponame].git
cd /home/git/repos/[reponame].git
git --bare init
git update-server-info
chown -R apache:apache /home/git/repos/[repomame].git

Now clone the project on a client, add some files and commit them. When pushing them for the first time use the following command:

git push origin master

NOTE: If this is done by the usual 'git push' command, a 'No refs in common and none specified; doing nothing.' error will be issued.

git/git_cheatsheet.1360136331.txt.gz · Last modified: 2013/02/06 08:38 by deva