Skip to content

git cmds

September 23, 2014

1. Create central repo:
ssh <user>@<host>
cd path/above/repo
git init –bare my-project.git

2. Clone a local copy:
git clone <repo> [<directory>]
git clone ssh://john@example.com/path/to/my-project.git
cd my-project

3. configuration:
git config –global user.name “Wang Jun”
git config –global user.email a@b.com
git config –system core.editor vim
#git config –global –edit

repo specific

4. log
git log –author=”<pattern>”
git log –grep=”<pattern>
git log <since>..<until>
git log –author=”John Smith” -p hello.py

5. checkout
git checkout a1e8fb5 hello.py
git checkout HEAD hello.py
git revert <commit>
git rebase <base>

# Start a new feature
git checkout -b new-feature master
# Edit files
git commit -a -m “Start developing a feature”
# Edit more files
git commit -a -m “Fix something from the previous commit”

# Add a commit directly to master
git checkout master
# Edit files
git commit -a -m “Fix security hole”

# Begin an interactive rebasing session
git checkout new-feature
git rebase -i master

Git best practices:
https://wiki.duraspace.org/display/FCREPO/Git+Guidelines+and+Best+Practices#GitGuidelinesandBestPractices-CommitMessages

From → Uncategorized

Leave a Comment

Leave a comment