01 October 2016

Git on Inux: Creating a New Git Repository

Install Git

  1. Use the package manager to install git:
    CentOs: yum install git
    Ubuntu: apt-get install git

Initialise a Local Repository

  1. Change to your local git repository directory e.g.
    mkdir gitrepo
    cd gitrepo
  2. Initialise git:
    git init

Add a Remote Path

You might want to cache your credentials:
git config --global credential.helper "cache --timeout=3600"
  1. Ensure you're on master locally:
    git checkout master
  2. Add a remote path e.g.:
    git remote add origin [path]
    e.g. https://[somename].visualstudio.com/DefaultCollection/_git/[SomeProject]
  3. Set the local 'master' to track the remote 'master':
    git branch --set-upstream-to=origin/master master

Set the Default Git User

  1. Set your email:
    git config --global user.email "you@example.com"
  2. Set your name:
    git config --global user.name "Your Name"

Update your files

  1. Pull from remote: git pull
  2. Set a global ignore (or it will add system files): echo "*" > .gitignore
  3. Add files to the repo: git add .
    You'll need to explicitly add files as we have a global ignore
  4. Commit your local changes: git commit -m"Some commit message"
  5. Push to remote: git push

No comments:

Post a Comment