Samples for using Git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir myclonedrepo && cd myclonedrepo | |
git clone $REPOSITORY_URL | |
cd $PROJECT_NAME | |
git status | |
# create a new file and add | |
echo "print('new')" > newpythonfile.py | |
cat newpythonfile.py # displays the new python file | |
#add the file and commit the change into the feature27 branch | |
git add newpythonfile.py | |
# see what has changed | |
git status | |
# commit | |
git commit -m 'added newpythonfile.py' | |
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir myclonedrepo && cd myclonedrepo | |
git clone $REPOSITORY_URL | |
# create a branch named 'feature27' | |
git branch feature27 | |
git branch | |
#displays the current branches that you have locally, * shows current branch | |
# switch to the 'feature27' branch | |
git checkout feature27 | |
git branch | |
#displays the current branches that you have locally, * shows current branch | |
# create a file. used your edtior. but for the demo do something simple | |
echo "print('new')" > newpythonfile.py | |
cat newpythonfile.py # displays the new python file | |
#add the file and commit the change into the feature27 branch | |
git add newpythonfile.py | |
git status | |
git commit -m 'added newpythonfile.py' | |
# make additional changes | |
echo "print('new with changes')" > newpythonfile.py | |
git commit -m 'updated newpythonfile.py' | |
# Then when you are happy, merge with the master branch | |
#pull any updates that have been made from the master | |
git pull origin master | |
git commit -m 'merged newpythonfile.py' | |
# resolve merge commits and push your feature branch to the respository | |
git push | |
# should do a pull request here | |
# ready to update master banch | |
git checkout master | |
ls | |
#the new file is not there, so let's merge feature27 branch with the master branch | |
git merge feature27 | |
# check to see if the file is there | |
ls | |
#the newpythonfile.py file is in the master branch | |
# push to the master branch | |
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "print('local change')" > newpythonfile.py | |
cat newpythonfile.py | |
git commit --all -m "change print statement on local machine" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git remote -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir myclonedrepo && cd myclonedrepo | |
git clone $REPOSITORY_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git add . | |
git commit --all -m "fixed merge with master on newpythonfile.py" | |
git status | |
# Your branch is ahead of 'origin/master' by 2 commits. | |
# check to see what might have changed while you were working | |
git pull | |
# should be up to date and ready to push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORGANIZATION_URL="https://dev.azure.com/user" | |
PROJECT_NAME="newproject" | |
az extension add --name azure-devops | |
az devops configure --defaults organization=$ORGANIZATION_URL \ | |
project=$PROJECT_NAME | |
#the previous command creates a repo name such as: | |
REPOSITORY_URL="https://dev.azure.com/$ORGANIZATION_URL/$PROJECT_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git remote add origin https://strategicdatatech@dev.azure.com/strategicdatatech/azdays/_git/azdays | |
git push -u origin --all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REPOSITORY_URL="https://strategicdatatech@dev.azure.com/strategicdatatech/azdays/_git/azdays" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORGANIZATION_URL="https://dev.azure.com/user" | |
PROJECT_NAME="newproject" | |
# create GitHub repo in portal | |
REPOSITORY_URL="https://github.com/$ORGANIZATION_URL/$PROJECT_NAME.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git init | |
git status #should have nothing outsetanding | |
git remote #should have no remote repository linked already | |
git remote add origin $REPOSITORY_URL | |
# check to see what is connected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment