03-13-2019 11:04 AM - edited 03-13-2019 11:05 AM
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.
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.
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.
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.
Confirm you've done things right using ssh -T <username>@bitbucket.org as shown.
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.
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
git pull origin master
(replace master with [branch name] if using branchgit 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
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 notesat this point the changes are staged locally, you can do multiple commits locally before having to push to the central repo.
git push
rectifies the central repo with your local repo (more on pull requests later)WIP #TODO
03-14-2019 02:53 PM - edited 03-14-2019 02:53 PM
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
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.
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