Skip to content

Instantly share code, notes, and snippets.

@thirdj
Forked from cyberswat/git-init.sh
Created March 21, 2017 08:47
Show Gist options
  • Save thirdj/97618109f16af4ad0ff2104fbd6903ce to your computer and use it in GitHub Desktop.
Save thirdj/97618109f16af4ad0ff2104fbd6903ce to your computer and use it in GitHub Desktop.
Initialize git repo and make first commit
# switch to the jenkins user
[root@li220-252:~] su jenkins
jenkins@li220-252:/root$
# Move into the jenkins directory
jenkins@li220-252:~$ cd /var/lib/jenkins/
# Intialize a git repository
jenkins@li220-252:~$ git init
Initialized empty Git repository in /var/lib/jenkins/.git/
# Add your github repository as remote origin
jenkins@li220-252:~$ git remote add origin git@github.com:cyberswat/jenkins-example-configs.git
# Set global configs for git
jenkins@li220-252:~$ git config --global user.name "Jenkins"
jenkins@li220-252:~$ git config --global user.email jenkins_email@youremail.com
# Add relevant xml files and commit changes
jenkins@li220-252:~$ git add *.xml
jenkins@li220-252:~$ git add users/*/config.xml
jenkins@li220-252:~$ git commit -a -m "Initial Commit"
[master (root-commit) d7b66d9] Initial Commit
12 files changed, 174 insertions(+), 0 deletions(-)
create mode 100644 config.xml
create mode 100644 hudson.maven.MavenModuleSet.xml
create mode 100644 hudson.model.UpdateCenter.xml
create mode 100644 hudson.scm.CVSSCM.xml
create mode 100644 hudson.scm.SubversionSCM.xml
create mode 100644 hudson.tasks.Ant.xml
create mode 100644 hudson.tasks.Mailer.xml
create mode 100644 hudson.tasks.Maven.xml
create mode 100644 hudson.tasks.Shell.xml
create mode 100644 hudson.triggers.SCMTrigger.xml
create mode 100644 nodeMonitors.xml
create mode 100644 users/cyberswat/config.xml
# Push commits up to the remote repository
jenkins@li220-252:~$ git push -u origin master
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
Counting objects: 16, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (16/16), 3.47 KiB, done.
Total 16 (delta 1), reused 0 (delta 0)
To git@github.com:cyberswat/jenkins-example-configs.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
jenkins@li220-252:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment