amin $>ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/<homedir>/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/<homedir>/.ssh/id_rsa
Your public key has been saved in /Users/<homedir>/.ssh/id_rsa.pub
Copy public key file contents to Clipboard
pbcopy < ~/.ssh/id_rsa.pub
paste your Public ket to github.com /settings /New SSH key
Setting up ssh as key Authentication Mechanism
Under userhome dir
~/.ssh/config
Host github.com
User git
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
here id_rsa is the private key file
public key - setup to use ssh key as auth mecchanism
Every git project has a .git folder -update
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@github.com:/ameenmohamed/clouddemo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
change url to git@github.com:/<repo> this could be https://.. if git clone was done using https
Set up Git on your machine if you haven't already.
mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin git@bitbucket.org:qadricoders/arduinoprojects
Create your first file, commit, and push
echo "Amin Mohammed" >> contributors.txt
git add contributors.txt
git commit -m 'Initial commit with contributors'
git push -u origin master
Great job, now you're all set up! Get started coding or create a team and invite people to work with you.
git fetch --all
git reset --hard origin/master
Overwrite non Conflicting changes
Like Hedgehog I think the answers are terrible. But though his might be better, I don't think it is as elegant as it could be. The way I found to do this is by using "fetch" and "merge" with a defined strategy. Which should make it so that your local changes are preserved as long as they are not one of the files that you are trying to force an overwrite with.
first do a commit of your changes
git add .
git commit -m "auto dev server commit"
then fetch the changes and overwrite if there is a conflict
git fetch origin master
git merge -s recursive -X theirs origin/master
Commit Single file
git commit -m ‘IDM-0000’ C:\amroot\allworkspaces\GIT\IDM\sif-module\services-3.2\src\test\resources\dbunit\tck\Section.xml
git push origin master
create branch and push to remote
$ git checkout -b feature_branch_name
... edit files, add and commit ...
$ git push -u origin feature_branch_name
git branch --set-upstream-to=origin/develop
git checkout -b <branch-name> <origin/branch_name>
for example in my case:
git branch -a * master origin/HEAD origin/enum-account-number origin/master origin/rel_table_play origin/sugarfield_customer_number_show_c
So to create a new branch based on my enum-account-number branch I do:
git checkout -b enum-account-number origin/enum-account-number
To check what is changed in current file
git diff --changed /myfile.txt
check what changed before running git add
git diff myfile.txt
git config --global credential.helper store
git config --global credential.helper 'store --file C:/<path>/security/.ameenmohamed-gitcreds'
$ git config --global user.name "ameen"
$ git config --global user.email ameen@hybridacumen.ie
$ git config --global credential.helper "store --file C:/<path>/security/.ameenmohamed-gitcreds"
To remove a local branch from your machine:
git branch -d the_local_branch
To remove a remote branch:
git push origin :the_remote_branch
git config --global user.name "ameenm"
git config --global user.email ameen@domain.com
# Reset the index to the desired tree
git reset 56e05fced
# Move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
# Update working copy to reflect the new commit
git reset --hard