banner



How to Create New Project in Powershell and Upload to Git

git github visual studio code git add all git commit -m message Fork from another repo git clone git pull git push infrastructure as a code iaas scripting devops.png

Part 1 Git version control integration in Visual Studio Lawmaking
Part 2 Git chief branch source command integration in Visual Studio Code
Part three Git clone version command integration in Visual Studio Code

I accept already wrote few manufactures on how to use git earlier, but they where completely for Visual Studio Code,  GUI with piddling exposure to command line. In this article I volition perform the same tasks using consummate git commands. I accept already downloaded and installed git application fromhttps://git-scm.com/downloads. Git is a command line tool a distributed version-control system for tracking changes in source code during my DevOps scripting development. Information technology helps me to interact my all scripting work amongst my colleagues and acts as good Key repository, information technology also helps to track changes in any files and tin can check in going point in time to review what changes where made when committing/pushing files. Git works very well for local repository. GitHub.com is a central Git repository hosting service, but information technology adds many of its ain features. GitHub provides a centralized Web-based graphical interface. It also provides access control and several collaboration features, such as a pull requests, wikis and bones task management tools for every twenty-four hours projects.

Solved Visual studio Code brand sure yous configure your user.name and user.email in git

First to starting time I accept created an account on github.com, After login create a new repository (Basically it is a binder/directory contains all the project lawmaking/scripts files, including revision history) by pressing + button on the right peak side of the screen, select New repository from the list. Provide repository a name and description (optional), I am keeping this repo public so anyone can view it and we can likewise choose who tin can alter it to it by assigning permissions later. Press Create repository.

git github.com create new repository public private git commands powershell code as a service automation infrastructure as a code ps1 .png

In one case the repository is created This shows some very basic useful information regarding git command line introduction and how to quick setup. Grab/copy the git url location with HTTPS (Another protocol you can use is SSH), this will require later.

github.com git init git add README.md git commit -m first commit git remote add orgin https github.co .git git push -u origin master devops automation infrastructure as a code.png

I take opened my PowerShell and using oh-my-posh module to add together flavors to my PowerShell console. That helps to enhances the prompt and git operations. I am creating a folder called Git-Demo.

New-Item -Path D:\Scripts -Name Git-Demo -ItemType Directory

I volition keep all the my codes/script on the same directory later on, go the the directory to Git-Demo.

Ready-Location D:\Scripts\Git-Demo

It is empty. Run below command to initialize the empty repository on the binder, Every time yous run git control keep middle on the prompt head it says principal with color greenish (means at that place are no changes inside directory everything is up to date null to stage), it is a master root branch also can be called first base co-operative

git init

It creates .git folder, This binder contains actual version control with all the metadata regarding this local git repository, all the changes will exist captured in the folders. I am creating kickoff file call README.md (I volition telephone call it help file, information technology has all the information regarding to my projects, scripts, howto etc.)

Write-OutPut "# vCloud-lab -Test Readme" >> README.physician

As soon equally I generate a new file, prompt colour changes to Yellow with +1, ways there is new file added. (first digit with + plus alphabetic character represents new files count added to the folder, 2d digit with ~ tilda character says this much of files are modified, and the last digit with - minus sign betoken deleted files count), Because I have added a single file it is showing +1 as a count.

git.exe basics new-item -path scripts -itemtype directory set-location git init .git initialized empty git repository write-output powershell visual studio code readme.md master branch.png

The git add together command adds a change in the working directory to the staging area. Equally below command I am merely calculation one file to the staging expanse, If y'all have multiple file you can use . (dot) or * (star) and proceed checking status with git condition. The git status command displays the state of the working directory and the staging expanse.

git add together .\README.md
git status

Next apply Git Commit. The commit control is used to save your changes to the local repository, -chiliad means message and information technology is mandatory.

git commit -m "beginning demo commit"

When I commit to the local repository, it immediately change the colour of prompt with back to green color logs with 1 file inverse, 1 insertion(+). As far all is good and everything is added to local repository nothing pushed to centralized github repo, at present I can brand as much every bit modifications to the files and keep adding and committing to local repo. All the code is stored locally, Before pushing the local changes to github, it requires to mention which online github.com repository you lot want to push information, apply the same HTTPS git url shown earlier. This is a one time command.

git remote add origin https://github.com/username/vCloud-lab.git

Next beginning pushing information to online github repository.

git push -u origin primary

When you lot add a remote url, effort to push, for the first time it will endeavor to authenticate to github.com and prompts y'all for to add together credentials. Because I am using it on visual studio code, it is asking me for additional permissions. I am using Windows 10, credentials are stored under your accounts Credential Manager in encrypted form and then you don't have to type user name and password again. Regarding this if you are facing error bank check my article.

Remote: Permission to UserName/repo.git denied to OtherUserName fatal: unable to access 'https://github.com/UserName/repo.git/': The requested URL returned error: 403

git github.com git comiit -message first commit git remote add origin https github.com .git master repository master branch devops infrasturcture as a code iaac IAAS.png

One time file is pushed online you can view it on github.com by refreshing information technology on browser. Now brand few more tries, add together, change and delete files with git add, commit, push button command and see the changes offline/online.

github.com readme.md git init git commit git add all files and folders branch code pull requests security pr tags actions infrastructure as a code iaas automation devops scripts.png

Side by side I will create a branch for better collaboration with my colleagues. A Git co-operative is substantially an independent line of development. It means me and my team volition non make any straight modification/changes to the Master, in layman term instead I will copy the the Main folder, give the folder name, make changes on the copied folder, once work is washed merge the changes with Master branch. if require delete the the co-operative I was working on to continue repository look cleaner. You can check the branches list with beneath command.

git branch

I accept only 1 base branch - master and it is * starred means I am onto the co-operative, any changes I make, will be done under master co-operative, here also when I create new branch it will be created on acme of selected * starred co-operative and data is cloned from the branch. Create a new co-operative using below command.

git branch vcloud-lab-projects

Now list the branches  again. New branch is populated, all the changes are stored locally it is not all the same pushed online on GitHub, the web screenshot here shown just for information purpose.

git co-operative

To change branch and start working on new branch, use below control.

git checkout vcloud-lab-projects

Once co-operative is changed detect the head of prompt, information technology switches to new branch. Whatsoever changes nosotros make will reverberate here only and master co-operative will be untouched.

visual studio code git branch git checkout switched to branch default master repository github.com tags git automation version control source control infrastructure as acode iaac infrastructure coding as a service.png

Next I have copied 2 powershell ps1 script files on the binder (using explorer), when I simply employ ls command the prompt changes to yellow showing 2 new files added. There are 2 untracked files. Add the all files in git. You can use beneath command to see the status and add untracked files

git condition
git add .

Check the status again, run Commit with message to save them to git repository.

git condition
git commit -a 'Add scripts to branch'
git status

Bank check the status once more, prompt is green , This shows on which you are now, Nothing to commit, working tree is clean.

git stauts git add . git status git commit -m add scripts oh my posh powershell github.com demo powershell as a code infrastructure as a code iaac service online bitbucket.png

You tin view the changes online at present by refreshing github.com in browser, on the master branch there are no new files, click on the chief button and choose the branch vcloud-lab-projects. All the newly added files are visible on the new branch now.

github.com change branch master code add files md help file add scripts to branch infrastructure as a code releases feature add git status commit add push pull.png

Next I will merge the changes made on from vcloud-lab-projects to primary, I am all the same on the vcloud-lab-project, and to proceed farther I will checkout to principal branch.

git checkout master

Once switched to master branch y'all can verify no .ps1 files visible before added and there is withal only sole README.doc file be.

Microsoft Powershell github.com visual studio code git demo ls git checkout branch master devops scripting infrastructure as a code IAAS source control version control git commit.png

Check the prompt I am on the master co-operative now. To start merging use below control.

git merge vcloud-lab-projects

listing the files, all looks good, Check the prompt now, color changes to Magenta  with upward arrow, which means all the merging is washed locally, To push information technology on online github repo, use below command.

git push

Refresh github.com page and switch to chief branch now you will run across pushed files.

github.com git merge  master powershell automation ps1 git push ls infrastructure as a code iaas git commit master packages releases command git.exe basics.png

In the last, if you lot desire to delete branch, once work is completed, below command helps you to perform the job on local git repository.

git co-operative -d vcloud-lab-projects

To delete branch on centralized github.com repository apply as beneath control.

git push origin -d  vcloud-lab-projects

Next refresh web folio and verify by clicking chief button, other branch no longer exists.

git branch -d deleted branch github.com git push origin -d project up to date infrastructure asa code iaas coding as a service powershell automation devops delete.png

Useful Articles
Resolved: Git warning LF will be replaced by CRLF in file
Creating an internal PowerShell module repository
Powershell Azure Inventory GUI Utility

godfreyhatevesserom.blogspot.com

Source: http://vcloud-lab.com/entries/devops/Step-by-Step-guide-to-push-your-first-project-to-github-com

0 Response to "How to Create New Project in Powershell and Upload to Git"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel