Sources : git-scm gitextensions.github.io (For UI) Using certificates with git
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.
Installation:
Git commands:
1. Have a local directory and willing to push it into git repository?
cd <LOCAL_DIR>git initgit add -allgit commit -m 'Initial commit'git remote add origin '<GIT_REPOSITORY_URL>'git push origin mastergit push2. Have a git repository url, want to pull it down to local?
git clone '<GIT_REPOSITORY_URL>'3. Push changes from local to repository.
git add --allgit commit -m "Message to indicate changes in current."git push4. Remove a file
git rm filegit commit -a -m "message"git push5. Create local branch from current.
git checkout -b <NEW_BRANCH_NAME>6. Check current branch.
git branch7. Switch to remote branch not available on local.
git fetch origin #brings all remote branch to local.git branch -v -a #lists all fetched branches available to switch to.git checkout -b <BRANCH_NAME_TO_SWITCH> #this will switch to said branch8. Pull changes from remote branch.
git pull origin <BRANCH_NAME>9. Ignore files and folder while commit. follow simple steps below.
1. Create a file named .gitignore beside directory named .git (within your project folder).
2. Add name(s) or regular expression(regex) pattern(s) one on each line and save the file. e.g.-
build .gradleNote:- .gitignore file should be commit as well, in order to apply rules on other people's commits as well.
10. Push locally created branch to remote
git push -u origin <LOCAL_BRANCH_NAME>11. Discard all local uncommitted changes.
git checkout .12. Discard changes of any specific file.
git checkout -- <FILE_TO_DISCARD>git status #Lists all changed filesgit add <FILE1> <FILE2> <FILEn> #stages changes to commitgit remove <FILEn> #for deleted filesgit commit -m "<BRANCH NAME> : <SHORT MESSAGE>" #commits staged changesgit push origin <BRANCH NAME> #Pushes commit branch to origin(repo).why : Git requires network and user level configurations which sometimes is hectic, hence for ease of use and security reasons bitbucket, github, etc are available. These also removes need of hardware and its maintenance burden.
Yet, How to setup git server in my local infra: Source: git-scm.com
We will need list of users and their id_rsa.pub file. Assumed we have 2 developer and a server node in our network.
we want to host git repo(git-repo1.git) on server 'S' and user 'A' on Node 'N1' and user 'B' on Node 'N2' will be using this repo. ssh-keygen -t rsa can be used to generate user's id_rsa.pub files on each user's node.
Steps: On S node:
Steps: On N1&2 Node:
Resolve conflicts:
Problems & Solutions:
#Git Fails to clone a repository due to network security. (Certificates required.)
Use http.sslCAInfo param :
git config --global http.sslCAInfo <CERTIFICATE_FILE_PATH>git clone <REPOSITORY>#Git bash completion not working in centos 7