Washington Community Group

cancel
Showing results for 
Search instead for 
Did you mean: 

git, LabVIEW and team development [3/12/2019 meeting]

Hey all thanks for coming last night.

 

I copied a internal wiki article that I have been slowing building up on using git with LabVIEW.  It is rough but has some good stuff in it. 

 

Any info that people have please share.

 

See you all soon. 

 

Gitting going

 

Assuming Windows here just because most of us in the HW group use Windows. But most of this should apply on Mac/Linux as well.

  1. Download GIT
  2. Install GIT, make sure to include it in your %PATH%
  3. Make sure that you have a Bitbucket account setup. This can be setup using you Fresh/Google login credentials. If you have any questions talk to Steve Heulet, he is our Bitbucket/Atlassian admin.
  4. Associate your GIT environment with Bitbucket. Much of this step will use the information found Atlassian's Set Up An SSH Key documentation in section Set up SSH for Git on Windows under step 3.

Open GIT Bash (or GIT CMD, probably). In Windows 8.1 and newer, press Windows key and type in "GIT Bash").

Create an SSH Key, following the example below.

Note the location of the keys; if you used the default key location (blank) and default passphrase (blank) as above, these will live in "/c/Users/Fresh/.ssh/id_rsa". You'll need to open the .pub public key in this folder later.

Add the key to the ssh-agent using eval and ssh-add as shown below.

Untitled.png

Note the location of the keys; if you used the default key location (blank) and default passphrase (blank) as above, these will live in "/c/Users/Fresh/.ssh/id_rsa". You'll need to open the .pub public key in this folder later.

Add the key to the ssh-agent using eval and ssh-add as shown below.

Untitled.png

Add the public key to Bitbucket settings. If you followed the example above, this will live in "/c/Users/Fresh/.ssh/id_rsa.pub". Open that file in Notepad and copy all of the contents. Open Bitbucket in web browser. Go to your account Settings and SSH Keys (bottom left icon >> Settings >> SSH keys). Click Add key. Label your key whatever and paste the public key you copied above in the *'d box and click "Add key" in the dialog box.

 

Untitled.png

Confirm you've done things right using ssh -T <username>@bitbucket.org as shown.

Untitled.png

Now finally clone a private Fresh Consulting repo! Be sure to set the directory to your desired home for your clone. Example shown below, cloning this wiki.

Untitled.png

GITing work done- Your git cheat sheet 

Workflows

There are two major schools of how people use git. Centralized workflow and branching workflow. For a more detailed explanation see this article.

 

 

Centralized is more like using SVN

  • clone repo (the command is in the browser usually)
  • making sure you have the latest code git pull origin master (replace master with [branch name] if using branch
  • do your work
  • ADD add your work to the repo (called staging in git langauge)

git add -A adds all changed files in repo
git add . adds all changed files in the directory that your in git add /folder/file.file adds a given file

  • commit this commits the staged change to the local repo git commit Brings up vim for you to enter your commit message if you don't know vim this will just make you angry. Using vim is easy if you know how to do it; hit i to insert text, hit escape to bring up the 'menu', type :qw to write the commit notes to git. git commit -m "notes notes notes" easier way to write commit notes

at this point the changes are staged locally, you can do multiple commits locally before having to push to the central repo.

  • push git push rectifies the central repo with your local repo (more on pull requests later)

Branch Workflow Example

WIP  #TODO

Message 1 of 2
(3,412 Views)

Working on this for our own team, enjoy. 

git Cheat Sheet

Typical Workflow

MgaV9.png

git pull reaches out to the remote and pulls the latest version down, will trigger a merge if there are conflicts

git status

Do your work

git add [filename] stages a specific file for commit to the local repository
git add -A stages all files that are different from the HEAD for commit to the local repository
git add . stages all files that are in lower level folders for commit to the local repository

When you are ready to create a checkpoint. This only commits the code to a place in the local repository. The remote remains unchanged.

git commit prompts you to write a commit message and commits your staged changes to the local repository
git commit -m "Commit Message here" sets your given commit message and commits your staged changes to the local repository

After committing locally you can keep working and making more commits or you can push to the remote.

Pushing to remote.

git push pushes the local changes to the remote repository if nothing has changes on the remote it should just go up

Resolving push errors

Most commonly the issue with pushing is that there have been changes to files on the remote since your last pull. Resolution to this is using the git pull before you push.

Resolving pull errors

Pull errors most commonly result in there being changes in both the local and remote to the same file. For text files there is a merge process. Binary files (.vi, .vit, *.ctl ect) either need an external diff tool or you can choose 'ours' or 'theirs'

If you want to go back and un-stage commits when you get this error you will first have to use the git merge --abort to cancel the merge

0 Kudos
Message 2 of 2
(3,386 Views)