8000 GitHub - jonatanmv/git-utils: Git cheatsheet for reference of handy command.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jonatanmv/git-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Git Utils

Quick reference for git use on your projects.

Git lifecycle

Setup... And starting !

Initialization

$ cd /Users/user/project/src
$ git init

Getting help

These commands are nice because you can access them anywhere, even offline.

$ git help <verb>
$ git <verb> --help
$ man git-<verb>

Verifying configuration

$ git config --list --show-origin
$ git config --list

Setup your info

If not already done (as global config for example) setup your name and email.

$ git config --global user.name "Your Real Name"
$ git config --global user.email "you-email@@users.noreply.github.com"

Setting up local repository

If your start from an existing project clone it.

$ git clone git@github.com:jonatanmv/Git-Utils.git

or

$ git clone https://github.com/jonatanmv/Git-Utils local_directory

Setting up remotes

You can check your remotes info with git remote. For example, when you clone a repository it will add automatically the origin remote. So git fetch origin fetches any new work that has been pushed to that server since you cloned or fetched.

$ git remote -v
$ git remote show origin

And you add remotes like this:

$ git remote add origin git@github.com:jonatanmv/Git-Utils.git
$ git remote add paul https://github.com/paulboone/Git-Utils

Or change from ssh to https:

git remote set-url origin https://github.com/jonatanmv/Git-Utils.git

Create the repository on github website and push your repository from the command line:

git push -u origin master

So you will download lates changes on remotes with git fetch <remote>. fetch only download info not the actual files. For that you will use pull (It will fetch and download changes).

$ git pull origin

Adding files

$ git add *.c
$ git add LICENSE

Checking status of your files

$ git status

Commit

$ git commit -m 'initial project version'

Ignoring files

You can easily create a .gitignore file this way:

$ cat .gitignore
__pycache__
*~
*.pyc
.DS_Store
.gitignore
logfiles/

Here another .ignorefile

# ignore all .a files
*.a

# but do track lib.a, even though you're ignoring .a files above
!lib.a

# only ignore the TODO file in the current directory, not subdir/TODO
/TODO

# ignore all files in any directory named build
build/

# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt

# ignore all .pdf files in the doc/ directory and any of its subdirectories
doc/**/*.pdf

Commit history

$ git clone https://github.com/schacon/simplegit-progitx1x1x

Push !

$ git push

In case commands are blocked by email privacy then:

$ git config --global user.email "you-email@@users.noreply.github.com"
$ git commit --amend --reset-author

About

Git cheatsheet for reference of handy command.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0